2
#/r/AskOuija

thing1 = ("1: My mom always told me to ....")
thing2 = ("2: I don't .... ")
thing3 = ("3: Go .... yourself")

print("1: My mom always told me to ....")
print("2: I don't .... ")
print("3: Go .... yourself")

choice = int(input("Please enter the number of the chosen one: "))

if choice == 1:
    print("1: My mom always told me to ....")
    print(thing1[27:32])
    one = input("Enter a letter [Type done when done]: ")
    one = input("Enter a letter [Type done when done]: ")
    one = input("Enter a letter [Type done when done]: ")
    one = input("Enter a letter [Type done when done]: ")
    print(thing1)
    if one == "done":
        print(thing1)

用户一一输入字母,最终产品应填写省略号

用户一一输入字母,最终产品应填写省略号

用户一一输入字母,最终产品应填写省略号

用户一一输入字母,最终产品应填写省略号

也许这超出了我的范围,我什至不确定

4

1 回答 1

0
#/r/AskOuija
# All phrases put into a nice list
phrases = ["0: My mom always told me to ....", "1: I don't .... ", "2: Go .... yourself"]

# For every phrase inside phrases, go ahead and print the phrase
for phrase in phrases:
   print(phrase)

# Now the user inputs their choice (range of 0 to 3)
choice = int(input("Please enter the number of the chosen one: "))

# Spit back out the selected choice
print(phrases[choice])
print("....")
res = ""

# Now loop four times and concatenate the chars inputted by the user
for i in range(4):
  temp = input("Enter a letter [Type done when done]: ")

  # Gotta check just incase some hooligan tried to enter more than one char
  while len(temp) > 1:
    print("Re-enter a letter. Your last entry was too long")
    temp = input("Enter a letter [Type done when done]: ")
  res += temp

print(phrase[choice].replace("....", "res"))

现在你不必重复每个短语的输出块,你可以让它超级动态。希望这是有道理的。我有点清理了你的代码。有点玩得很开心哈哈。

另外为了将来参考,您正在寻找的功能是我使用的.replace()

是有关该功能的更多信息

于 2018-09-09T23:19:38.963 回答