In: Computer Science
Write a program that prints out the characters of a string each on a line and counts these characters. (Do not use the length function len() ).
Since you didn’t mention the language, I’m gonna go with Python since it is the closest match. Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
Note: Please maintain proper code spacing (indentation), just copy the code part and paste it in your compiler/IDE directly, no modifications required. If you face any indentation issues, refer to the attached screenshot and maintain proper indentation as on the image.
#code
#creating a string
text="I love Python"
#initializing character count to 0
count=0
#looping through each character in text
for c in text:
#printing character on a line
print(c)
#incrementing count by 1
count+=1
#displaying length/character count
print("Length:",count)
#output
#code screenshot