+ 1

Hey guys, pls help me with this code, I want it to choose a random number and it's not

seats =[1, 2 ,3,4,5,6,7,8,9,10] seats2 = random.choice(seats) print(str(seats2))

14th Apr 2022, 12:09 PM
Zanele
Zanele - avatar
4 Answers
14th Apr 2022, 12:26 PM
Abhishek Tandon
Abhishek Tandon - avatar
+ 3
Zanele , your code is missing the import of the module *random*: from random import choice seats =[1, 2 ,3,4,5,6,7,8,9,10] seats2 = choice(seats) print(str(seats2)) # no need to convert to string # when using a consecutive range of numbers, also randint() can be used from random import randint seats2 = randint(1, 10) print(seats2)
14th Apr 2022, 2:49 PM
Lothar
Lothar - avatar
+ 1
I was missing import random
14th Apr 2022, 4:56 PM
Zanele
Zanele - avatar
0
Thank you
14th Apr 2022, 4:51 PM
Zanele
Zanele - avatar