There is a list: a = [1,2,3,4,5] I enter the ordinal number of the element from the keyboard: c = int (input ("Vvedi nomer")) then I start the cycle: for i, ii in enumerate (a): how to access any of the list items?

    1 answer 1

    It is obvious that you yourself answered your question:

    a = [1,2,3,4,5] for i, ii in enumerate(a): print(a[i]) c = int(input("Введите номер:")) try: print(a[c]) except Exception as exc: print(str(exc)) 
    • one
      in your example, a[i] is ii you can directly ii (having come up with the best possible name), instead of using an index. You can simply: print(exc) instead of print(str(exc)) . - jfs
    • @jfs, thanks for the clarification, that's it. - user3416803