Just before I ask the question I would like to say that I am very new to Python so what ever I ask might be simple to do.
My question is this: How do I stop the script after this question has been answered.
s1 = input("Is your phone freezing/stuttering? ")
if s1 == "Yes" or s1 == "yes":
print("Try deleting some apps and this might help with your problem")
if s1 == "No" or s1 == "no":
def foo():
while True:
return False
So what I exactly want here is when the user replies with 'Yes' I want the solution to come up and the script to stop or if possible even restart.
A simple exit could be reach by this.
I also used the lower function so it will look a bit more pythonic
With just a simple loop:
s1 = "yes"
while s1 == "yes":
s1 = input("Is your phone freezing/stuttering? ").lower()
Good luck !
What you could do is create a loop around it
x = 4
while x == 4:
s1 = input("Is your phone freezing/stuttering? ")
if s1 == "Yes" or s1 == "yes":
print("Try deleting some apps and this might help with your problem")
if s1 == "No" or s1 == "no":
def foo():
while True:
return False
break #<-- only if you want the program to end after false#
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.