Python Forum

Full Version: casting types rewrite
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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
The print line has 3 opening brackets but only 2 closing brackets, add another close bracket to the end
(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
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}.')