擅长:python、mysql、java
<pre><code>def comparision():
loop = True
while loop:
print ("welcome to the comparision function: ")
a = int(input(("Enter your number for a value a , then hit enter key:")))
b = int (input("Enter your second number for value b, then hit enter key:"))
answer = ''
if a > b:
answer = 1
elif a == b:
answer = 0
else:
answer = -1
print (answer)
response = str(input("Would you like to perform another comparison? (yes/no) :"))
while response.lower() not in ['yes', 'no']:
response = str(input("please enter proper response: "))
if response.lower() == 'yes'
continue
elif response.lower() == 'no'
print ("Thank you, have a great day!")
break
if __name__ == '__main__':
comparision()
</code></pre>
<p>如果您使用的是python 2.7:</p>
^{pr2}$
<p>希望这有帮助。谢谢</p>