Why this code doesn't work | Sololearn: Learn to code for FREE!
Новый курс! Каждый программист должен знать генеративный ИИ!
Попробуйте бесплатный урок
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

10th Mar 2020, 1:34 AM
Glory222
Glory222 - avatar
3 ответов
+ 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())
10th Mar 2020, 1:54 AM
Denise Roßberg
Denise Roßberg - avatar
+ 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
10th Mar 2020, 1:37 AM
かんでん
かんでん - avatar
+ 1
If you really want to use dice(x,y), then you could do something like this https://code.sololearn.com/cDaVGZgf2fN2/?ref=app
10th Mar 2020, 7:23 AM
Rik Wittkopp
Rik Wittkopp - avatar