how do I make the program ask for a name and then alternate the result in uppercase and lowercase?
Example:
How is your name? george
Hello GeOrGe
Thanks
how do I make the program ask for a name and then alternate the result in uppercase and lowercase?
Example:
How is your name? george
Hello GeOrGe
Thanks
print("How is your name?");
name = input();
list(name)
letters = list(name)
final_word = ""
for x in range(len(name)):
if x % 2 == 0:
final_word += letters[x].upper()
else:
final_word += letters[x].lower()
else:
print("Hello" + final_word)
I think this code should work
you can use list comprehension
-
s = input()
s = ''.join(item.upper() if index%2 ==0 else item.lower() for index,item in enumerate(s))