0
Why this code doesn't work
This code here guys does not work but the second one does work, can someone explain to me what's actually going on here? https://code.sololearn.com/cXNaaDS41dPC/#py
3 Respostas
+ 4
I would remove the parameters of the function because I don't see any reasons for them.
def dice():
x = random.randint(1, 6)
y = random.randint(1, 6)
return f"[{x} , {y}]"
print(dice())
+ 2
The dice() function requires 2 parameters. In the print() function you called dice() and gave it arguments x and y, however x and y is not defined. You don't have to require 2 parameters for the dice() function really, since x and y is just going to be reassigned to be a random integer inside the function
+ 1
If you really want to use dice(x,y), then you could do something like this
https://code.sololearn.com/cDaVGZgf2fN2/?ref=app