Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
User input - list
#1
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)
Reply
#2
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.
Reply
#3
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)
Reply
#4
you can't append if a list doesn't already exist.
at beginning, add:
kod = []
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Unable to access the user input value given to daterangepicker klllmmm 1 472 May-26-2021, 09:16 PM
Last Post: nilamo
  Problem restricting user input in my rock paper scissors game ashergreen 6 893 Mar-25-2021, 03:54 AM
Last Post: deanhystad
  Looking for a way to loop until user enters from a list? PythonW19 7 631 Mar-21-2021, 08:56 PM
Last Post: PythonW19
  LinkedList by User Input SantiagoPB 5 958 Mar-03-2021, 09:54 PM
Last Post: deanhystad
  User input/picking from a list AnunnakiKungFu 2 542 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  Generate Random operator, take user input and validate the user mapypy 4 601 Feb-03-2021, 08:41 PM
Last Post: nilamo
Question Reset list if user regrets Gilush 1 706 Dec-05-2020, 10:55 AM
Last Post: Gilush
  Loop back through loop based on user input, keeping previous changes loop made? hbkpancakes 2 907 Nov-21-2020, 02:35 AM
Last Post: hbkpancakes
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 845 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  How to time a user's input Tbot1000 2 886 Aug-31-2020, 09:39 PM
Last Post: Larz60+

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020