Answer the question
In order to leave comments, you need to log in
Why is the for loop not working properly?
The problem is that there are 5 attempts to find out if the hidden word contains the letter that the user indicated or not.
if this is the code:
import random
WORDS =("питон", "анаграмма", "простая", "сложная", "ответ", "подстаканник")
word = random.choice(WORDS)
i = 5
dor = input('Назовите вашу букву ')
while i!=0:
for item in word:
if item == dor:
print('Да')
i -= 1
dor = input('Назовите вашу букву ')
Say your letter a
Say your letter o
Yes
Say your letter p
Yes
Say your letter and
Yes
Say your letter s
import random
WORDS =("питон", "анаграмма", "простая", "сложная", "ответ", "подстаканник")
word = random.choice(WORDS)
i = 5
dor = input('Назовите вашу букву ')
while i!=0:
for item in word:
if item == dor:
print('Да')
else:
print('Нет')
i -= 1
dor = input('Назовите вашу букву ')
What is your letter o
Yes
No
No
No
No
What is your letter
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question