简体   繁体   中英

How do I stop an input when i entered a certain word?

I´m doing a small work for college and i need to stop a certain input when u entered a certain word in python?

I tried this but it isn´t working

  if (entrance == 'STOP'): 
      break;

FIrst of all always provide the maximum information you can about your question. Secondly the brackets around the if conditional and the semi column are redundant in python.

For your problem, try using while loops to test the input of the user. Something like,

 while input() != 'STOP':
 # insert code here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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