L
L
LeGDieS2021-08-13 21:02:30
Python
LeGDieS, 2021-08-13 21:02:30

How can I make it so that when I write n the command ends and when I write y it continues?

import time
p = 1
i = 1
y = 1
a = int(input())
while i < 101:
print("Formating /data . . .", i , "%")
i = i+1
time.sleep( 0.1)
print("formatind /data complete")
if a < y:
while p < 101:
print("Removing system. . .", p , "%")
i = i + 1
time.sleep(5)
print( "System deleted! Please restart your device: sm-a115a 32/2")
else:
print('deleting canceled')

Answer the question

In order to leave comments, you need to log in

1 answer(s)
T
Tim Novikov, 2021-08-14
@LeGDieS

If I correctly understood the meaning of your program, then you need to do the following

import time
while True:
    per = input()
    if per == "n":
        continue
    elif per == "y":
        сюда твой код(импорт я прописал выше, его не надо второй раз
    else:
           pass

So your code is only executed if the variable "y" is entered
*ps guys like it please I need points so I can ask more questions. thanks in advance

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question