main.py149 chars8 lines
This code initializes the variables idx
and numchars
to 0, and a string variable astr
. Then, the code loops through each character in the string astr
. For each character, numchars
is incremented by 1. If the character is an 'i', then idx
is incremented by 1.
At the end of the loop, idx
will contain the number of 'i' characters in the string astr
, and numchars
will contain the total number of characters in the string astr
.
gistlibby LogSnag