Can i have some help with Explicit String Conversion?


#1

can i get some help i cant figure out what to do im doing what it says i read what some other people have said to do for it but its not working this is what its coming up with when i do some thing Traceback (most recent call last):
File "python", line 3, in
TypeError: cannot concatenate 'str' and 'float' objects im not sure what im doing wrong


#2

It means you are trying to put together a float ( 5.0 ) and a string ( "Yay" ). You must convert either.


#3

you CAN'T add non-string values to strings
ex: "spam" + 5 is not a valid python expression
you must convert the integer value (the number 5) into string using str() method
so it should be: spam + str(5)
=======
hint: you can use strings & numbers straightforward in multiplication!
for example: "spam" * 5 is a valid python expression
that will print the string "spam" 5 times with no space between it's characters!