简体   繁体   English

如果用户说“不”,我该如何做到这一点,以便我的代码可以返回一行

[英]How do I make it so my code can return to a line if the User says No

textinfo = str(input("Insert Text here:"))
LocateInText = str(input("Insert What needs to be found (i.e words, numbers, ect):"))
Confrim = str(input("Are you sure? This may take a bit, Y or N:"))

if Confrim == "N":
    find: LocateInText

I am trying to make it so that when the user says N (no) It repeats LocateInText to correct themselves我正在努力做到这一点,以便当用户说 N(否)时,它会重复 LocateInText 来纠正自己

If the textinfo does not need to be edited you can add the LocateInText and Confirm into a while loop and break it when user confirms it.如果不需要编辑文本信息,您可以将 LocateInText 和 Confirm 添加到 while 循环中,并在用户确认时将其中断。

textinfo = str(input("Insert Text here:"))
while True:
    LocateInText = str(input("Insert What needs to be found"))
    Confrim = str(input("Are you sure? This may take a bit, Y or N:"))
    if Confirm == 'Y':
        break
# do next thing here

暂无
暂无

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

相关问题 我如何制作它以读取用户所说的内容并使用它来扮演角色? discord.py - How do i make it so it reads what the user says and uses it to make a role? discord.py 如果用户在我的 if 语句后回答“否”,我如何才能让代码再次询问您的姓名? - How do I make it so that the code will ask you your name again if the user answers no after my if statement? 如何制作程序,以便用户可以指定文件名? - How do I make my program so that the user can specify a file name? 如何对我的 discord 机器人进行编码,以便它可以在用户设备上执行谷歌搜索? - How do I code my discord bot so that it can perform google search on the user device? 事件可以执行命令吗? 如果是这样,我怎样才能让我的人这样做? - Can an event execute a command? If so, how can I make my one do so? 如何查看密码变量是否在一行内,以便我的代码可以继续? - How can I see if my password variable is within a line so that my code can proceed? 如何让我的代码读取特定行? - How can i make my code read specific line? 为什么我的python代码的运行时间这么长,我该怎么做才能让它运行得更快? - Why is the runtime of my python code so long, and what can I do to make it run faster? 如何使我的代码在我的一个 function 中包含两个“while”循环? - How do I make it so my code includes both "while" loops in my one function? 如何使我的代码响应用户输入 - How can I make my code respond to user input
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM