+ 1
tuple inside randint
n = (1,10) print(randint(n)) the code above gives error. how to use the tuple for randint. and why is it doesn't work. thanks
4 Antworten
+ 6
randint() requires 2 arguments. use * operator to unpack the tuple
+ 3
ah i see. so my n tuple count as 1. my code works now. thank you
+ 2
from random import randint
n = (1, 10)
print(randint(*n))
0
from random import randint
n = (2,20)
Printf (randint(*n))