0

how to increase count whenever a specific input is entered in python

please help it is not working

1st Aug 2022, 12:25 PM
Mussarat Rani
Mussarat Rani - avatar
8 Answers
+ 2
Try putting that if-statement in the same for-loop where you're making the variable for ask. You can leave the print statement out of it though.
1st Aug 2022, 1:18 PM
Justice
Justice - avatar
+ 2
please make better use of the tags next time you ask a question, they are a great place to specify the language you use.
1st Aug 2022, 3:07 PM
Apollo-Roboto
Apollo-Roboto - avatar
+ 1
Do you have an attempt that you can show us?
1st Aug 2022, 1:03 PM
Justice
Justice - avatar
+ 1
people = int(input("how many people are there?")) count = 0 for i in range(people): ask = input("you like anime") if ask == "yes": count += 1 print(count)
1st Aug 2022, 1:08 PM
Mussarat Rani
Mussarat Rani - avatar
+ 1
You need to indent the if statement such that it is part of the for loop.
3rd Aug 2022, 11:40 AM
John Doe
0
yes
1st Aug 2022, 1:07 PM
Mussarat Rani
Mussarat Rani - avatar
0
how??? Justice
2nd Aug 2022, 9:09 AM
Mussarat Rani
Mussarat Rani - avatar
2nd Aug 2022, 9:09 AM
Mussarat Rani
Mussarat Rani - avatar