syntax error with print()???

0 votes
asked Apr 19 by QuiiKy _ (420 points)
so here's my problem:

print("It's worth " + str(score) + " points")

     /\

SyntaxError: invaild syntax

4 Answers

+1 vote
answered Apr 19 by Manuel Mateo (1,170 points)
selected Apr 22 by QuiiKy _
 
Best answer
The issue is you typed str(score) and python tried to treat it like a function. Simply type

print("It's worth " + score + " points")

instead. Make sure score actually has a value.
commented Apr 21 by Cotasam Nemano (140 points)
You're not wrong about "python tried to treat it like a function", though. But sorry, the str() function to convert its argument to string(in this case, he do a number) so that you could combine many strings into one using "+" operator.
commented Aug 5 by 318126512038 PENTAKOTA MOHAN MANOJ (150 points)
, instead +   will work
0 votes
answered Apr 21 by Cotasam Nemano (140 points)
This line of code is fine. Maybe the ones above. Let me see your program.
–2 votes
answered Jul 23 by Rateesh Bhagwanani (160 points)
You haven't assigned any values with the variable "score" and you also have to add commas(,), as in:

print("It's worth", +str(score)+, "points"
0 votes
answered Jul 24 by 318126512038 PENTAKOTA MOHAN MANOJ (150 points)
the value of ur score might be in digits .

str cannot convert digits

try print("It's worth {} points".format(score))
Welcome to OnlineGDB Q&A, where you can ask questions related to programming and OnlineGDB IDE and and receive answers from other members of the community.
...