how to use print statement in python3?

0 votes

I am getting this syntax error whenever I am using print statement. 

print "Hello World"

Jun 25, 2018 in Python by misc.edu04
• 1,430 points

2 answers to this question.

0 votes

In python3, print statement is a function, not a statement. So here you have to pass the items you need to print in parenthesis. For example:

print("Hello world")

answered Jun 25, 2018 by code.reaper12
• 3,450 points
0 votes

The print statement has been replaced with a print() function in Python3. Examples:

Old: print "Hello World!!"
New: print("Hello World!!")
Old: print "square of 3 is ", 3*3
New: print(​"square of 3 is ", 3*3​)

Old: print z,           # comma suppresses newline
New: print(z, end=" ")  # Appends a space instead of a newline
You can also customize the separator between items, e.g.:
print("The cube of 9 is <", 9**3, "> !", sep="")


The cube of 9 is 729!
answered Jul 16, 2018 by Mrunal
• 680 points

Related Questions In Python

0 votes
2 answers

Unable to use print statement in python3

print will work when you use print("Your ...READ MORE

answered Feb 14 in Python by Shashank
• 1,350 points
0 votes
1 answer

Raw_input method is not working in python3. How to use it?

raw_input is not supported anymore in python3. ...READ MORE

answered May 4, 2018 in Python by aayushi
• 750 points
+1 vote
2 answers

How to use the pass statement in Python

In Python programming, pass is a null statement. The ...READ MORE

answered Apr 5 in Python by anonymous
0 votes
1 answer

How to use nested if else statement in python?

The working of nested if-else is similar ...READ MORE

answered Nov 19, 2018 in Python by Nabarupa
0 votes
1 answer

How to write inline if statement for print in Python?

Inline if-else expression must always contain the else ...READ MORE

answered Dec 4, 2018 in Python by Nymeria
• 3,520 points

edited Dec 6, 2018 by Nymeria 1,517 views
+1 vote
2 answers

how can i count the items in a list?

Syntax :            list. count(value) Code: colors = ['red', 'green', ...READ MORE

answered Jul 6 in Python by Neha
• 330 points

edited Jul 8 by Kalgi 420 views
0 votes
1 answer

convert integer to strings

Yes, you can str() function. For example: a=10 str(a) output-'1 ...READ MORE

answered Jun 25, 2018 in Python by code.reaper12
• 3,450 points