1. Engineering
  2. Computer Science
  3. python string manipulation the assignment is to create a user...

Question: python string manipulation the assignment is to create a user...

Question details

Python String Manipulation

The assignment is to create a user defined function that takes any string (example: 'hello') and capitalize the even letters ('hElLo'). In the example with 'hello', the second letter, (index 1) the fourth letter are capitalized (index 3). I believe that my code is correct, but for some reason it's not accepting the answer. What am I doing something wrong? Thanks!

Functions #10: skyline Define a function called myfunc that takes in a string, and returns a matching string where every even letter is uppercase, and every odd letter is lowercase. Assume that the incoming string only contains letters, and dont worry about numbers, spaces or punctuation. The output string can start with either an uppercase or lowercase letter, so long as letters alternate throughout the string Remember, dont run the function, simply provide the definition To give an idea what the function would look like when tested: myfuncCAnthropomorphi sm) #Output: aNtHrOpOm0rPhIsM | Added note: this exercise requires that the function return a string. Print statements will not work here. A Oops, your solution is incorrect 1- def myfunc(string): 2 lst = [] 3 for i in range (0,len(string)): exercise.py False is not true: This is incorrect if ix2-0: 1 lst.appendCstringi]) else: Lst.append(string[i].upper a -join(lst) return(a)

Solution by an expert tutor
Blurred Solution
This question has been solved
Subscribe to see this solution