Using for loop you can capitalize every other letter in Python programming. Iterate over the given string and capitalize car every other char with the if condition. Add both types of char into the new string.
Example capitalise every other letter in a string in Python
Simple python example code has a function to capitalize every other letter.
def mock(s): res = "" i = True for char in s: if i: res += char.upper() else: res += char.lower() i = not i return res print(mock("Hello word program"))
Do comment if you have any other code or doubts on this Python capitalize topic.
Note: IDE: PyCharm 2021.1.3 (Community Edition)
All Python Examples are in Python 3, so Maybe its different from python 2 or upgraded versions.
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.