擅长:python、mysql、java
<p>以<code>"\r"</code>结尾会导致下一个输出从上一行的开头开始。然后可以用适当数量的空格(<code>" " * len(text)</code>)替换输出</p>
<pre><code># import time
print("Welcome to the memory game.")
print("Choose difficulty level :")
print("1. Easy")
print("2. Medium")
print("3. Hard")
print("4. Very Hard")
x = input("press '1' for easy, '2' for medium, '3' for hard and '4' for very hard : ")
if x == '1' :
print("You chose level 1, easy.")
print("I will give you 3 objects and you have to type then in the correct order to gain points.")
print("Not cAsE SeNSitIvE")
text = "Ship, Money, Python"
obj = print(text, end="\r")
time.sleep(1)
print(" " * len(text), end="\r")
ez = input().upper()
if ez in [string.upper() for string in
['Ship, Money, Python',
'ship,money,python',
'Ship,Money,Python',
'ship, money, python']]:
print("Correct")
else :
print("Wrong")
print("The answer was : Ship, Money, Python")
</code></pre>