+ 1
i want to make a code that split a word to letters and then plus the number of positon of each letter together and then etc
s=0 word=input("Enter A Word:") lenght=len(word) letterlist=list(word) letterlist=[ch for ch in word] print(letterlist) chars=['a''b''c''d''e''f''g''h''i''j''k''l''m''n''o''p''q''r''s''t''u''v''w''x''y''z'] nums=['1''2''3''4''5''6''7''8''9''10''11''12''13''14''15''16''17''18''19''20''21''22''23''24''25''26']
5 Réponses
+ 4
One way:
x=input()
print(*(''.join((b, str(a)))
for (a, b) in enumerate(x, 1)))
+ 2
enumerate takes an iterable and puts a number to each element, like 'a' becomes (0, 'a'). If we add a second argument, we can specify where the counting starts.
For every element of that, we now turn the number into a string, then connect the two strings using the join method.
After that we get a succession like 'a1', 'b2' and so on, which we unpack using the *, and print.
+ 2
HonFu thankU your answer will help me too much
0
If you want this to be some kind of secret cipher, you should change the single digit numbers into two digit numbers: 1, 2, 3 into 01, 02, 03. Otherwise, you won't be able to decipher it.