+ 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

6th Apr 2023, 12:53 AM
Alif Vareza
Alif Vareza - avatar
4 odpowiedzi
+ 6
randint() requires 2 arguments. use * operator to unpack the tuple
6th Apr 2023, 2:12 AM
Kaminorsabir Kamin
Kaminorsabir Kamin - avatar
+ 3
ah i see. so my n tuple count as 1. my code works now. thank you
6th Apr 2023, 2:27 AM
Alif Vareza
Alif Vareza - avatar
+ 2
from random import randint n = (1, 10) print(randint(*n))
6th Apr 2023, 2:18 AM
Kaminorsabir Kamin
Kaminorsabir Kamin - avatar
0
from random import randint n = (2,20) Printf (randint(*n))
6th Apr 2023, 5:29 PM
Asim Farheen ⭐⭐🤺👿👿
Asim  Farheen ⭐⭐🤺👿👿 - avatar