Print String in Python
Question:
I tried running this basic python script to print something, and it doesn’t seem to be executing properly.
name = "Tyler";
print{name};
I am getting this error:
File "C:Userstylermain.py", line 2
print{name};
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
I tried changing line 2 to:
print(...)
but it prints out
Ellipsis
, not my name.
Answers:
You don’t need semicolons in Python
The issue was the use of curly braces. Call your variable name
with print()
like this:
name = "Tyler"
print(name)
I tried running this basic python script to print something, and it doesn’t seem to be executing properly.
name = "Tyler";
print{name};
I am getting this error:
File "C:Userstylermain.py", line 2
print{name};
^^^^^^^^^^^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
I tried changing line 2 to:
print(...)
but it prints out
Ellipsis
, not my name.
You don’t need semicolons in Python
The issue was the use of curly braces. Call your variable name
with print()
like this:
name = "Tyler"
print(name)