r/pythonhelp • • Apr 18 '22

Assignment advice

Hi! I have been having trouble with this assignment problem. If anyone can help me with this I would greatly appreciate it.

The program says to write a function that accepts a string of arbitrary length as an argument and it should print out a list where each character in the original string is repeated and capitalized.

Call the function upper(my_string)

Example upper(“hi”)

[‘HH’, ‘II’]

2 Upvotes

4 comments sorted by

2

u/carcigenicate Apr 18 '22

What have you tried? What specifically do you need help with?

1

u/NoButterfly4448 Apr 18 '22

I got stuck, not sure how to fix my code to make it do what the assignment wants. So far this is what I have.

def upper(my_string):

   return my_string.upper(), “,”.join([x+x for x in my_string])

2

u/IncognitoErgoCvm Apr 19 '22

You're currently returning a tuple containing my_string.upper() and a string which you have erroneously joined from a list that is nearly creating what you actually wanted.

Get rid of the my_string.upper(), and the join. You can figure it out from there.

2

u/NoButterfly4448 Apr 19 '22

Thanks to your help I figured it out. Thank you so much!