用户一个字母一个字母输入,最终产品应填满椭圆

时间:2018-09-09 22:44:53

标签: python-3.x

#/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)

用户一个字母一个字母输入,最终产品应填满椭圆形

用户一个字母一个字母输入,最终产品应填满椭圆形

用户一个字母一个字母输入,最终产品应填满椭圆形

用户一个字母一个字母输入,最终产品应填满椭圆形

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

1 个答案:

答案 0 :(得分: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"))

现在,您不必重复每个短语的输出块,只需使其超级动态即可。希望这是有道理的。我有点清理您的代码。 Kinda玩得很开心哈哈。

另外,您正在寻找的功能是我使用的 .replace()

这里more information on the function