Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

Python Python Basics Functions and Looping Functions

Caleb Newell
Caleb Newell
12,562 Points

what is wrong with my code. and how do i fix it?

def yell(text): text = text.upper() number_of_characters = len(text)
result = text + "!" * (number_of_characters // 2) print(result)

yell = ("You are doing great")
yell = ("Don't forget to ask for help")
yell = ("Don't Repeat Yourself. Keep things DRY")
Cameron-Lee Rothenburg
Cameron-Lee Rothenburg
4,415 Points

I believe you are setting a variable called yell. You need to call a function.

yell("text to shout")

2 Answers

def yell(text): text = text.upper() number_of_characters = len(text) result = text + "!" * (number_of_characters // 2) print(result)

it should be like that, omit 4 spaces after creating a function

I am having the same issue, and I can not figure it out what to do. This is the message that I get: code line: def yell(text): text = text.upper() number_of_characters = len(text) result = text + "!" + ((number_of_characters) / 4) print(result)

yell("You are doing great!")
yell("Don't forget to ask for help!") yell("Don't repeat yourself. Keep things DRY")

TypeError: unsupported operand type(s) for //: 'int' and 'str'
treehouse:~/workspace$ python notifications.py
Traceback (most recent call last):
File "/home/treehouse/workspace/notifications.py", line 8, in <module>
yell("You are doing great!")
File "/home/treehouse/workspace/notifications.py", line 4, in yell
result = text + "!" + ((number_of_characters) / 4)
TypeError: can only concatenate str (not "float") to str

can someone tell me how to get around this issue?...thanks