import random
def diceroll():
x = random.randrange(1, 6)
print(x)
repeatroll()
def repeatRoll():
roll = input(print("Would you like to roll again?"))
if roll.upper()=="Y":
return diceroll()
elif roll.upper()=="N":
return print("You have chosen not to roll again")
else:
return print("Invalid input")
return roll
repeatRoll()
Can anyone explain to me why this returns None after the code asks for an input?
I always thought that it would be due to not having a return function.
I'm completely confused, I feel like the answer is obvious but i'm not quite getting it.
Help would be appreciated, thank you.
print() always return None
It doesn't return any value; returns None.
Since you called print() inside input().The print() returns none which is take as input by input()
Use :
print("Would you like to roll again?")
roll = input()