Reputation: 297
Sorry, I would like users to input a letter but I dun understand why the display will show a None.
import random
hangmanList = {"fruit":["apple","banana","orange"]}
topicList = ["fruit"]
randomTopic = random.choice(topicList)
wordList = hangmanList[randomTopic]
questionList = random.choice(wordList)
def main():
print("Welcome to the Hangman Game")
print("---------------------------")
print("Please choose 1 letter at a time")
print("Topic is: ",randomTopic)
guesses = input(print("Guesses: "))
main()
the output shows:
Welcome to the Hangman Game
Please choose 1 letter at a time
Topic is: fruit
Guesses: None
Upvotes: 0
Views: 38
Reputation: 22659
Should be
guesses = input('Guesses: ')
Currently it is None
because the print()
function does not return a value, thus it's result is None
. So
guesses = input(print('Guesses: '))
# is
guesses = input(None)
Upvotes: 1
Reputation: 177481
Just use:
guesses = input("Guesses: ")
print
returns None
. input
prints its argument as a prompt.
Upvotes: 1