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 trialRajesh Guleria
199 Pointsi have copied in ditto the lines here and yet i am getting an error message. Have called my file caps.py
line 7, in <module>
yell("You are doing great")
File "caps.py", line 4, in yell
result = text * "!" * (number_of_characters)
TypeError: can't multiply sequence by non-int of type 'str'
1 Answer
Jennifer Nordell
Treehouse TeacherHi there, Rajesh Guleria! You're really close! You have a typo. The variable text
holds a string. And the "!"
is also a string which you are then wanting to concatenate together and then multiply the exclamation point by the number of characters, which is an integer.
You typed:
result = text * "!" * (number_of_characters)
But you meant to type:
result = text + "!" * (number_of_characters)
Note the + between text
and "!"
. Those add the strings together
Hope this helps!
Arnold Ganga
1,698 PointsArnold Ganga
1,698 PointsThats it Jennifer,it really helps and the other thing is that the error came up when Rajesh typed this
result = text* "!"* *(number_of_characters)
the interpreter parsed through this line it reached the first *(multiplication operator ) it checked the first operand that is (text) which is a string and it went on to check the second operand that is "!" and found that it is a string as well so you can multiply a string data type with another string data type