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 26, 2018 in Python by misc.edu04
• 1,450 points
1,628 views

3 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 26, 2018 by code.reaper12
• 3,500 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 17, 2018 by Mrunal
• 680 points
0 votes

Brackets are required to print the output.

>>> a=9
>>> b='Testing'
>>> c=['Prog']
>>> print(a,b,c)
answered Nov 25, 2021 by anonymous

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, 2019 in Python by Shashank
• 1,370 points
1,269 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 5, 2018 in Python by aayushi
• 750 points
3,368 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, 2019 in Python by anonymous
1,070 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
1,265 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,560 points

edited Dec 6, 2018 by Nymeria 16,752 views
0 votes
2 answers
+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 7, 2019 in Python by Neha
• 330 points

edited Jul 8, 2019 by Kalgi 4,442 views
0 votes
1 answer
0 votes
1 answer

convert integer to strings

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

answered Jun 26, 2018 in Python by code.reaper12
• 3,500 points
556 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP