by CodeChum Admin
We've already counted digits before on a certain number, so how about doing it on strings and characters? There's a catch, though, since you're only going to count and see if the character exists at least twice in a string.
Are you up for the challenge?
Instructions
- Create two variables and assign them to an input() function. The first variable shall accept a single letter and the second variable shall store the inputted string.
- Using loops, count the number of times that the single letter appears on the inputted string, and when it appears at least twice in the string, print "Cody is really awesome"; else, print "Cody rocks".
- Tip: to make your code more efficient, use the break keyword to terminate the loop whenever the count of appearance of the single letter has already reached 2.
Comments