Iterating by character | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Iterating by character

hi, how do I go about this # create a program which gets the user input for car. first_name #create an empty string variable: new_name #iterate though letters in first_name #add each letter in new_name #capitalise if letter is an "I" or "o" #print new_name

6th Sep 2017, 11:02 AM
Daniel Bawa
Daniel Bawa - avatar
2 Answers
+ 1
This is a possible answer using for loop https://code.sololearn.com/cWZZITXbxiqJ/?ref=app You can shorten it by directly placing the input function after the "in" keyword in the loop
6th Sep 2017, 11:29 AM
spcan
spcan - avatar
0
Another way using string methods https://code.sololearn.com/cCgvxLJBgr4C/?ref=app
6th Sep 2017, 12:28 PM
spcan
spcan - avatar