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,380 points
26 views

2 answers to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
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="")

output:

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
22 views
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
94 views
+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
35 views
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
33 views
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,500 points

edited Dec 6, 2018 by Nymeria 574 views
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 1,400 points
67 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
20 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.