Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Python Python Basics Functions and Looping Functions

i don't know why, but i cant get upper case letters in this code for some reason.

def Word ( Name ): Value = Name.upper() number_chars = len(Name) result = Name + "!" * number_chars print(result)

Word("im bad at defining")

3 Answers

Dave StSomeWhere
Dave StSomeWhere
19,870 Points

Jassim,

First - Good move testing out your code :thumbsup:

Your issue is that you're just not using the variable that you put the upper() value into - you're still using Name, when you put it into Value.

Also, it is common to upper case a variable name for Classes only.

You might want to consider changing your code:

# your code with caps and using Value
def Word ( Name ): 
    Value = Name.upper() 
    number_chars = len(Name) 
    result = Value + "!" * number_chars 
    print(result)

Word("im bad at defining")

# Maybe consider something like:
def word ( name ): 
    value = name.upper() 
    number_chars = len(name) 
    result = value + "!" * number_chars 
    print(result)

word("im bad at defining")

# Just for fun - the code can be condensed to a 1 liner
def word(name): 
    print(name.upper() + ("!" * len(name))) 

word("im bad at defining")

# output from all above 
IM BAD AT DEFINING!!!!!!!!!!!!!!!!!!

Hello @jassim Al-Hatem, I think it is because you are assigning Name +'!' to result. Instead I think you want to assign Value + '!' to result as Value is the uppercase version of the Name variable.

oh alrighty i get now. thanks alot. you guys are great :).