+ 2

Python result none

I am trying to do a dice roller. I have done a generic die I wrote a multiple dice roll script but i get a none as a final roll How can i avoid this none import random def de(cote): b=cote return (random.randint(1,b)) def des(nombre,cote): a=nombre #nombre de des a rouler b=cote #valeur des des a rouler c=1 #compteur while c<=a: c=c+1 print(de(b)) print(des(3,6))

21st Jun 2018, 8:49 PM
Alexandre Venne
Alexandre Venne - avatar
8 Respuestas
0
like you said, if I run it with out print by calling de() none dosen't show. Thanks for your time and help!!
24th Jun 2018, 12:44 AM
Alexandre Venne
Alexandre Venne - avatar
0
you defined variable b twice you defined b inside de(cote) and you called it de(b) while b is defined within de() and it has value cote, which has a value b which is cote .......
21st Jun 2018, 8:57 PM
TheCoder04
0
I see the mistake and I think I found a way to improuve my code. Thank you for the help.
22nd Jun 2018, 1:19 AM
Alexandre Venne
Alexandre Venne - avatar
0
I made this modification but still have the none after my five roll import random def de(nombre,cote): a=nombre b=cote c=1 if a<=1: return (random.randint(1,b)) else: while c<=a: c=c+1 print(random.randint(1,b)) print(de(5,6))
22nd Jun 2018, 1:38 AM
Alexandre Venne
Alexandre Venne - avatar
0
you dont necessarily have to make variables a and b, because you can just call nombre and cote, and the rest of your code looks good and you've made a really good improvement
22nd Jun 2018, 5:36 AM
TheCoder04
0
import random def de(nombre,cote): c=1 if nombre<=1: return (random.randint(1,cote)) else: while c<=nombre: c=c+1 print(random.randint(1,cote)) print(de(5,6)) outputs 5 numbers then none because nombre is greater than 1 (its 5) and c starts with 1 and is after every random added by 1 so after 5 random numbers its 6 and will output none because there is no other if or elif or else statement that is true
22nd Jun 2018, 5:42 AM
TheCoder04
0
I can't figure out how to avoid the output of none
22nd Jun 2018, 11:09 PM
Alexandre Venne
Alexandre Venne - avatar
0
i tried some things and found out that the problem is in the pribt(de(5,6)) part
22nd Jun 2018, 11:56 PM
TheCoder04