D
D
DimaD0106d2021-06-19 15:30:45
Python
DimaD0106d, 2021-06-19 15:30:45

How to make a limited number of loop execution?

import time
while 3:
    time.sleep(0.5)
    print('СЛОВА: Привет, Пока, Пошли')
    look = input()
    time.sleep(0.5)
    if look == 'Привет':
        print('Hello my friend')
    elif look == 'Пока':
        print ('bye my friend')
    elif look == 'Пошли':
        print('let`s play together')


I want the loop to run 3 times!

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Daniil Shevkunov, 2021-06-19
@DimaD0106d

Read about the basics of python!
for i in range(3):
print(i)
The while loop checks if the condition is true, and any number other than 0 is considered true, while 3: this is an infinite loop

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question