There is a code:
s=str(input("Enter string")) print(s) for i in range(len(s)): print(i) How to create a letter assigned to a number and start with something like 1:
"qwerty" <--(строка) [1] [q], [2] [w]... and so on ?
There is a code:
s=str(input("Enter string")) print(s) for i in range(len(s)): print(i) How to create a letter assigned to a number and start with something like 1:
"qwerty" <--(строка) [1] [q], [2] [w]... and so on ?
for i, e in enumerate(s): print('[{0}] [{1}]'.format(i + 1, e)) enumerate takes the starting number as the second parameter if you write enumerate(s, 1) (or enumerate(s, start=1) ), then you can do without + 1 in the loop. - insolor ei = [[e, i] for e, i in enumerate(input('Enter string: '), start=1)] print(ei) from itertools import chain p = '[{}] [{}],\n'*len(ei) print(p.format(*chain(*ei))) out:
Enter string: qw [[1, 'q'], [2, 'w']] [1] [q], [2] [w], Source: https://ru.stackoverflow.com/questions/579352/
All Articles