【发布时间】:2017-04-13 22:15:47
【问题描述】:
我想在 Python 3 中创建一个程序,允许用户输入单词的字母数量,以及一些字母。
例如:
>> Input how many letters there are in the word
> 5
>> Put _ if no letter is shown, and letter that is shown down
> _ell_
>> Possible finds: Hello, Mello
>> Update the search
> Hell_
>> Final find: Hello
>> Restart?:
> Yes
我真的不知道如何用恰当的语言来解释这一点,但正如您所说,您是开发人员,所以我相信您明白这一点。
您让用户输入单词中的字母数量。
然后你让user input _ 显示为空白字母和正确的字母(st_ing >> string)
然后它会提出一些与来自字典数组或文本文件的搜索相匹配的单词(数组我的意思是words = ["word1", "word2", word3"] 等..)
然后如果没有超过 1 个查找,您可以键入以缩小搜索范围
一旦只有1个find,会提示重启,然后yes=restart。
我是 python 新手,所以这对我来说可能是最复杂的,这就是我问你的原因!
我在问这会有多复杂,如果可能的话,我会怎么做。我已经开始了,这就是我现在所拥有的:(记住我刚刚开始)
two_word = ["hi", "ai", "no", "id"]
three_word = ["run", "buy", "tie", "bit", "fat"]
four_word = ["help", "file", "edit", "code", "user"]
five_word = ["couch", "cough", "coach", "stars", "spoon", "sunny", "maths"]
letter_count = input("How much letters are there?: ")
letter_count = int(letter_count)
if letter_count == 2:
wordlist = two_word
elif letter_count == 3:
wordlist = three_word
elif letter_count == 4:
wordlist = four_word
elif letter_count == 5:
wordlist = five_word
else:
print("Improper entry.")
guess = input("The word right now: ")
blanks = guess.count("_")
#I don't know how to check for certain letters and how to convert _ to the word in the wordlist
#That is why I'm asking
【问题讨论】:
-
到目前为止,您还没有真正描述您面临的问题是什么,您只是描述了您正在尝试做的事情。
-
到目前为止你自己有什么想法?
-
“但正如您所说,您是开发人员,所以我相信您明白这一点。”除非您代表您付出了有意义的努力,否则我们不会在这里为您编写代码。 StackOverflow 不是代码编写服务。
-
我可以为你写代码。你愿意付给我多少钱? :P 开个玩笑。 SO 不是按需编码服务,如果您的问题显示出一些努力,我们可能只会为您提供帮助。我们可以一起解决您面临的问题,而不是解决您的整个任务
-
我添加了我的尝试,这在我刚开始时很糟糕,而对于您的专业人士来说,它可能是愚蠢的代码!请告诉我如何做哈希中的事情
标签: python arrays python-3.x