Hello, OnlineGDB Q&A section lets you put your programming query to fellow community users. Asking a solution for whole assignment is strictly not allowed. You may ask for help where you are stuck. Try to add as much information as possible so that fellow users can know about your problem statement easily.

syntax error with print()???

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

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


SyntaxError: invaild syntax

4 Answers

+1 vote
answered Apr 19, 2020 by Manuel Mateo (1,190 points)
selected Apr 22, 2020 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, 2020 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, 2020 by 318126512038 PENTAKOTA MOHAN MANOJ (150 points)
, instead +   will work
0 votes
answered Apr 21, 2020 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, 2020 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, 2020 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.