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.
Login
Login
OnlineGDB Q&A
Questions
Unanswered
Tags
Ask a Question
Ask a Question
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
python-3
asap
Your answer
Your name to display (optional):
Email me at this address if my answer is selected or commented on:
Email me if my answer is selected or commented on
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
–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"
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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))
Your comment on this answer:
Your name to display (optional):
Email me at this address if a comment is added after mine:
Email me if a comment is added after mine
Privacy: Your email address will only be used for sending these notifications.
Anti-spam verification:
To avoid this verification in future, please
log in
or register.
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.
...