Python result none | Sololearn: Learn to code for FREE!

+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))

6/21/2018 8:49:56 PM

Alexandre Venne

8 Answers

New Answer

0

like you said, if I run it with out print by calling de() none dosen't show. Thanks for your time and help!!

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 .......

0

I see the mistake and I think I found a way to improuve my code. Thank you for the help.

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))

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

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

0

I can't figure out how to avoid the output of none

0

i tried some things and found out that the problem is in the pribt(de(5,6)) part