Python Forum

Full Version: Help for beginner :)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Hey guys,
I am very beginner and trying to code numbers to characters and reverse.
I always get an error on line 23. I have no idea how to solve this because i need the user to input a list of numbers.
Thanks for you help'

print('1 - budu kodovat text na cislo')
print('2 - budu kodovat cislo na text')
zadej = int(input('Zadej cislo 1 nebo 2'))



if zadej == 1:
    zakodovat = input('Co chces zakodovat?')
    delka = len(zakodovat)
    kod = ''
    for i in range(0,delka):
        pismeno = zakodovat[i]
        cislo = ord(pismeno)-96
        kod = kod + str(cislo)
    print(kod)
    

else:
    zakodovat2 = input('Zadej seznam')
    delka = len(zakodovat2)
    kod = ''
    for i in range(0,delka):
        cislo = int(zakodovat2[i])
        pismeno = chr(cislo+96)
        kod = kod + pismeno
    print(kod)
Please, always post the entire traceback that you get. We need to see the whole thing.
Take a time to read What to include in a post