+ 1
Can some one tell me what is the problem of this code?
counter =0 while(True) : str =input("Enter a String : ") for s in str : if s == 'a' counter =counter +1 print(counter)
3 Answers
+ 5
Oh in that case, if ur getting that error
Please provide : (colon) there, after if s == 'a':
Code ->
counter =0
while(True) :
str =input("Enter a String : ")
for s in str :
if s == "a":
counter =counter +1
print(counter)
+ 4
The loop never ends...
provide an exit case for the loop to break at some point and print the corresponding counter value.
0
GURURAJ KL I want that the loop never ends
i run the code and the message "Enter a String : " appears, after entering a string i get this error :
Traceback (most recent call this)
File "main.py" line 3 , in <module>
str = input("Enter a String )
File <String> , line 1 in <module>
Name Error : name 'a' is not defined
,,,,,,
line 3 is str = input("Enter a String )
and 'a' is my input