繁体   English   中英

如何解决最终问题以继续使用伪代码?

[英]How can I address final issue for continuation to pseudocode?

import random

print('Hello there! Welcome to the higher/lower game!!.')
high = int(input('Please enter a high number: '))
low = int(input('Please enter a low number: '))
# while low < high or high > low:
if low > high:
    print('Low must be lower than high number')
elif high < low:
    print('High must be higher than low')
correct_number = random.randint(low, high)
user_input = int(input('Enter guess between high and low number.'))

while user_input != correct_number:
    if user_input > correct_number:
        print('Nope, too high.')
        user_input = int(input())
    if user_input < correct_number:
        print('Nope, too low')
        user_input = int(input())

else:
    print('You got it right!')

到目前为止,我一直在努力,但是如果低高于高,我就会试图让代码打印出来,反之亦然。 我尝试过改变很多东西,但它继续在第 373 或 350 行返回错误。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM