Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
New to Python
#1
I'm new to Python; from a tutorial I got the following lesson for beginners:
"By default, each print statement prints text in a new line. If we want multiple print statements to print in the same line, we can use the following code:"
print("hello", end="")
Print("world")

print(Hello", end=" ")
Print("World")

but when I run the code, I get the following:
helloTraceback (most recent call last):
File "D:/Python/April 21 2020/3.py", line 2, in <module>
Print("world")
NameError: name 'Print' is not defined

Can anyone guide what is the problem?
Reply
#2
Function names are case sensitive. print has all lower-case letters.
Reply
#3
Please use proper tags when posting so we can follow your code as it should be. I have done it for you this time.
As "bolowfred" had pointed out you need to watch your code because python is case sensitive and "print" is always lowercase.

print("hello", end="")
Print("world")

print(Hello", end=" ")
Print("World")
but when I run the code, I get the following:
helloTraceback (most recent call last):
Error:
File "D:/Python/April 21 2020/3.py", line 2, in <module> Print("world") NameError: name 'Print' is not defined[/python]

I will also point out that you have a couple other errors in your code example.
Error 2:
#in line 1 you did not ad a space within your "" and this puts the words together as helloworld
print("hello", end="")
Error 3:
#you forgot to properly encase Hello in quotation "Hello"
print(Hello", end=" ")
Print("World")
As an example of clean coding for your example, you can simply write it this way for the same result:
print("hello world")
print("Hello World")
Output:
*** Remote Interpreter Reinitialized *** hello world Hello World
Hope this helps a little.
Enjoy...
"Often stumped... But never defeated."
Reply
#4
yes it worked, thank you so much bowlofred; stay blessed
Reply


Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020