Python Forum
taking input doesnt print as list
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
taking input doesnt print as list
#1
I am trying to get 10 scores from the user and print them out as a list. instead output is like this

Output:
please enter your discussions scores: 3 [3] please enter your discussions scores: 2 [2] please enter your discussions scores: 1 [1] please enter your discussions scores: 3 [3] please enter your discussions scores: 5 [5] please enter your discussions scores: 4 [4] please enter your discussions scores: 3 [3] please enter your discussions scores: 2 [2] please enter your discussions scores: 1 [1] please enter your discussions scores: 1 [1]
i=1
while i <=10:
    try: 
        my_list = []  
        my_list.append(int(input('please enter your discussions scores: '))) 
        i += 1
        print(my_list)
    
    except: 
        print('you made an error,please try again')

Still doesnt work when i print it outside like this

i=1
while i <=10:
    try: 
        my_list = []  
        my_list.append(int(input('please enter your discussions scores: '))) 
        i += 1
    
    except: 
        print('you made an error,please try again')
print(my_list)
Reply
#2
Define my_list before the loop.
Reply
#3
Thank you!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  print doesnt work in a function ony 2 232 Mar-11-2024, 12:42 PM
Last Post: Pedroski55
  difference between forms of input a list to function akbarza 6 928 Feb-21-2024, 08:02 PM
Last Post: bterwijn
  How do you get Python to print just one value in a list? 357mag 3 967 May-17-2023, 09:52 PM
Last Post: rob101
  user input values into list of lists tauros73 3 1,023 Dec-29-2022, 05:54 PM
Last Post: deanhystad
  Ldap3 Python print(conn.entries) doesnt work ilknurg 15 5,565 Dec-28-2022, 11:22 AM
Last Post: shad
  Print List to Terminal DaveG 2 1,408 Apr-02-2022, 11:25 AM
Last Post: perfringo
Exclamation question about input, while loop, then print jamie_01 5 2,615 Sep-30-2021, 12:46 PM
Last Post: Underscore
  User input/picking from a list AnunnakiKungFu 2 2,282 Feb-27-2021, 12:10 AM
Last Post: BashBedlam
  Group List Elements according to the Input with the order of binary combination quest_ 19 6,235 Jan-28-2021, 03:36 AM
Last Post: bowlofred
  I have two Same Code but One of them Doesnt Work beginner721 6 3,002 Jan-22-2021, 10:56 PM
Last Post: beginner721

Forum Jump:

User Panel Messages

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