79137720

Date: 2024-10-29 14:50:21
Score: 0.5
Natty:
Report link

You are overwriting the value of char which each loop iteration. This code will behave as you expect:

value = input("Input a string: ")
char = input("Input a character to count: ")[0]
count = 0
for c in value:
    if c == char:
        count += 1
print(f"The character '{char}' appears {count} times.")
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (0.5):
Posted by: Zico