为什么我会得到重复和“重复”;直到;将伪代码转换为Python程序时出错?

为什么我会得到重复和“重复”;直到;将伪代码转换为Python程序时出错?,python,pseudocode,Python,Pseudocode,我正在转换python程序中的伪代码,但是我被卡住了,并且给了我错误信息 重复 及 直到年龄>=最小年龄和最大年龄,然后 输出“错误-年龄必须在18到60之间” 其他的 输出“接受年龄” 恩迪夫 直到年龄>=min和年龄min=18 最大值=60 年龄=int(输入('你的年龄是多少?')) whilenot(min您可以使用if条件执行while循环,以在满足条件时突破 min = 18 max = 60 while True: print("what is your age?")

我正在转换python程序中的伪代码,但是我被卡住了,并且给了我错误信息

重复

直到年龄>=最小年龄和最大年龄,然后 输出“错误-年龄必须在18到60之间” 其他的 输出“接受年龄” 恩迪夫 直到年龄>=min和年龄
min=18
最大值=60
年龄=int(输入('你的年龄是多少?'))

whilenot(min您可以使用if条件执行while循环,以在满足条件时突破

min = 18
max = 60


while True:
    print("what is your age?")
    INPUT age # or some other command reading from input

    if age < min or age > max:
        print(“Error - age must be between 18 and 60 ")
    else:
        print("Age is accepted ")

    if age >= min AND age <= max:
        break
min=18
最大值=60
尽管如此:
打印(“您的年龄是多少?”)
输入年龄#或从输入读取其他命令
如果年龄<最小值或年龄>最大值:
打印(“错误-年龄必须在18到60岁之间”)
其他:
打印(“接受年龄”)

如果age>=min和age则
REPEAT…till
构造类似于许多语言中的
do…而
-循环

我可以想出两种解决方案:

while True:
    ...
    if <condition>:
        break
为True时:
...
如果:
打破

continue\u loop=True
继续循环时:
...
如果:
continue\u loop=False

这可能是您编写的代码的一个简单示例

    min = 18
    max = 60
    print("Enter your age")
    age = int(input())
    if(age < min or age > max):
        print("Error : Age must be between 18 and 60")
    else: print("Age is accepted and you age is "+ str(age))
min=18
最大值=60
打印(“输入您的年龄”)
年龄=整数(输入()
如果(年龄<最小值或年龄>最大值):
打印(“错误:年龄必须在18到60岁之间”)
其他:打印(“接受年龄,您的年龄为”+str(年龄))

重复,直到可以这样定义:

min = 0
max = 100
while true:
    age = int(input('age: '))
    if (min < age < max):
        print('age {0} accepted'.format(age))
        break;
    print('age should be between {0} and {1}'.format(min, max))
    age = int(input('age: '))
min=0
最大值=100
尽管如此:
年龄=整数(输入('age:'))
如果(最小值<年龄<最大值):
打印('age{0}已接受'。格式(age))
打破
打印('年龄应介于{0}和{1}之间。格式(最小值、最大值))
年龄=整数(输入('age:'))

请在输出程序中描述的代码下发布错误文本请向我们展示您在Python中已经做了什么-如果我们只看到伪代码,我们无法帮助您使用Python您的答案中有语法错误。-->“@IMCoins我猜他只是想完成这项任务,向他索要代码需要一段时间。但我同意我们应该让他们明白这不是“为我做”网站。我不知道你的评论中最让我不安的是什么。事实是
需要时间,他只是想把工作完成
,或者你同意我的观点,我们应该让人们理解这是一个帮助网站,而不是
为我做
代码网站,但是:我们无论如何都要做。@IMCoins这就像我做了一个e例外,不知道为什么。
continue_loop = True
while continue_loop:
    ...
    if <condition>:
        continue_loop = False
    min = 18
    max = 60
    print("Enter your age")
    age = int(input())
    if(age < min or age > max):
        print("Error : Age must be between 18 and 60")
    else: print("Age is accepted and you age is "+ str(age))
min = 0
max = 100
while true:
    age = int(input('age: '))
    if (min < age < max):
        print('age {0} accepted'.format(age))
        break;
    print('age should be between {0} and {1}'.format(min, max))
    age = int(input('age: '))