Python Forum
casting types rewrite
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
casting types rewrite
#1
I am meant to rewrite the end of the code.

The original code:
#!/usr/bin/python

# Don't change the variables here - do it in the print statement
Title = "Berserk"
Author = "Kentaro Miura"
prototypePremiereYear = 1988

print("The manga, \"" + Title + ",\" was written by " + Author + " and was premiered as a prototype in the year " + (prototypePremiereYear) 
My solution:
 #!/usr/bin/python

# Don't change the variables here - do it in the print statement
Title = "Berserk"
Author = "Kentaro Miura"
prototypePremiereYear = 1988

print("The manga, \"" + Title + ",\" was written by " + Author + " and was premiered as a prototype in the year " + (str(prototypePremiereYear))
The output:

Error:
offsec@python-scripting:~$ python typeCasting.py File "typeCasting.py", line 9 ^ SyntaxError: unexpected EOF while parsing
Any guidance would be appreciated
Yoriz write Jan-30-2024, 11:10 PM:
Please post all code, output and errors (in its entirety) between their respective tags. Refer to BBCode help topic on how to post. Use the "Preview Post" button to make sure the code is presented as you expect before hitting the "Post Reply/Thread" button.
Reply
#2
The print line has 3 opening brackets but only 2 closing brackets, add another close bracket to the end
Reply
#3
(Jan-30-2024, 11:13 PM)Yoriz Wrote: The print line has 3 opening brackets but only 2 closing brackets, add another close bracket to the end

Thank you
Reply
#4
Title = "Berserk"
Author = "Kentaro Miura"
prototypePremiereYear = 1988

# Using f-string for formatting
print(f'The manga, "{Title}," was written by {Author} and was premiered as a prototype in the year {prototypePremiereYear}.')
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020