0

抱歉,我希望用户输入一个字母,但我不明白为什么显示屏会显示无。

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

输出显示:

欢迎来到刽子手游戏


请一次选择1个字母

题目是:水果

猜测:无

4

2 回答 2

1

只需使用:

guesses = input("Guesses: ")

print返回Noneinput将其参数打印为提示。

于 2013-10-23T08:57:27.453 回答
1

应该

guesses = input('Guesses: ')

目前是None因为print()函数没有返回值,所以它的结果是None. 所以

guesses = input(print('Guesses: ')) 
# is
guesses = input(None) 
于 2013-10-23T08:57:57.210 回答