Computer Science, asked by Akbadahah, 1 month ago

Write a program that reads a string and then prints a string that capitalizes every other letter in the string. eg : passion becomes pAsSiOn.

Add File

Q. 3.2 Upload the screen shot out put of the above program
here.​

Answers

Answered by Equestriadash
12

The following co‎des have been written using Python.

s = input("Enter a string: ")

ls = list(s)

for i in range(1, len(s), 2):

   ls[i] = ls[i].capitalize()

es = ""

for i in ls:

   es = es + i

print(es)

Once a string is entered, you form a list out of it. You then start a for loop that traverses through the string and capitalizes every alternate letter using the capitalize() method. You then create another empty string and concatenate the elements of the list to print the final string.

Attachments:
Similar questions