Then.... x=int(input("Enter number of players")) for i in range(x): players[i]=input() print (players) | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Then.... x=int(input("Enter number of players")) for i in range(x): players[i]=input() print (players)

why is this bringing an error

24th May 2018, 11:36 AM
Nwankwo Valentine
Nwankwo Valentine - avatar
7 Answers
+ 4
merely look at your code,its easy to decipher youre trying to iterate over an array/list you haven't even created
24th May 2018, 11:48 AM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
+ 2
x=int(input("Enter number of players")) players=[] for i in range(x): players[i]=input() print (players)
24th May 2018, 12:32 PM
᠌᠌Brains[Abidemi]
᠌᠌Brains[Abidemi] - avatar
0
how
24th May 2018, 12:06 PM
Nwankwo Valentine
Nwankwo Valentine - avatar
0
The players array does not exist according to your code
24th May 2018, 12:13 PM
Zeki Gurbuz
Zeki Gurbuz - avatar
0
Just I want to get the number of players from user and store it in x var Then I want to get players name as list from the user
24th May 2018, 12:21 PM
Nwankwo Valentine
Nwankwo Valentine - avatar
0
where did i made an error according to it pls try elaborate
24th May 2018, 12:22 PM
Nwankwo Valentine
Nwankwo Valentine - avatar
0
then after getting it from the user then print it
24th May 2018, 12:23 PM
Nwankwo Valentine
Nwankwo Valentine - avatar