Issue
I'm trying to run a simple program in Python3, but I keep getting this error message after typing into the terminal python3 mario.py
:
File "mario.py", line 10
^
SyntaxError: unexpected EOF while parsing
I'm not sure why this is happening. Here is my code:
#from cs50 import get_int
height = int(input("Height: "))
if height < 1 or height > 8:
height = get_int("Height: ")
for i in range(height):
print(f"{"#" * i} {"#" * i}\n", end="")
I believe it has something to do with the way I'm formatting my print
function. I'm not sure which one of these to use: '
or "
I would love if you could help!
Solution
You have to alternate between "
and '
. Try this:
print(f'{" # " * i} {"#" * i}\n', end="")
Answered By - John Rayburn Answer Checked By - Gilberto Lyons (PHPFixing Admin)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.