Python Forum
User input - list - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: User input - list (/thread-16117.html)



User input - list - Ondra - Feb-14-2019

Guys, please, is there any way how to replace this bz user input? [10,20,10]
If I change the firts row to zakodovat2 = ['Insert list of numbers'] and write 10,20,10 manually then I always get an error... thanks for any advice!
zakodovat2 = [10,20,10]
    zakodovat2 = [10,20,10]
    delka = len(zakodovat2)
    kod = ''
    for i in range(0,delka):
        cislo = int(zakodovat2[i])
        pismeno = chr(cislo+96)
        kod = kod + pismeno
    print(kod)



RE: User input - list - Larz60+ - Feb-14-2019

Quote:If I change the firts row to zakodovat2 = ['Insert list of numbers'] and write 10,20,10 manually then I always get an error... thanks for any advice!
Not sure what you mean? Please show code example of this scenario.


RE: User input - list - woooee - Feb-14-2019

First, change kod to a list and append as you only print the last loop through the for
##    kod = kod + pismeno
    kod.append(pismeno)
print(kod)



RE: User input - list - Larz60+ - Feb-15-2019

you can't append if a list doesn't already exist.
at beginning, add:
kod = []