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
  EOF error while taking input ShishirModi 1 261 Sep-27-2020, 11:28 AM
Last Post: jefsummers
  Print max numbers in a list jimmoriarty 1 197 Sep-25-2020, 07:29 AM
Last Post: DPaul
  user input for multi-dimentional list without a prior iteration using input() Parshaw 6 349 Sep-22-2020, 04:46 PM
Last Post: Parshaw
  Print variable values from a list of variables xnightwingx 3 333 Sep-01-2020, 02:56 PM
Last Post: deanhystad
  Print the number of items in a list on ubuntu terminal buttercup 2 422 Jul-24-2020, 01:46 PM
Last Post: ndc85430
  How to print out multiple drinks instead of just one based on the input? jayfre 4 711 Jul-01-2020, 06:53 PM
Last Post: menator01
  code doesnt return anything ofrihemo 3 420 Jun-30-2020, 05:14 PM
Last Post: ofrihemo
  if conditions in the for indentation doesnt work ? Sutsro 4 514 Jun-27-2020, 12:15 PM
Last Post: Sutsro
  Taking brackets out of list in print statement pythonprogrammer 3 577 Apr-13-2020, 12:25 PM
Last Post: perfringo
  Taking Multiple Command Line Argument Input bwdu 6 612 Mar-29-2020, 05:52 PM
Last Post: buran

Forum Jump:

User Panel Messages

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