Reputation: 1
I trying to pritn with print commamd but ir doesnr work i got pyton and lesrning programation but i cannot do homewrok print command my teacher gived me homework is try to printing youre name but i cant its not workign on pyton i tryied the print comand and it dont do it gived me eror it says sintax error i cant print on pyton
i tri doinf print command on pyton window it dont work it gived me eror it says syntax Error i cant print on piton it said sintax error i wrote print(peter songo why ks it not working i wantign know why it not wokring
Upvotes: -4
Views: 72
Reputation: 157
TL;DR: It is not written as a string and the function isn't written properly. If you just started learning Python, that's OK! Read on.
You have given print(peter songo
to Python.
There are two issues to this.
To show to Python that you are writing words, you have to tell it that it is a string, otherwise it will think you are telling it something else that doesn't exist. Python knows that something is a string when there are two "
s or '
s around it.
Examples:
print("Hello World")
Notice the "
s there.
print('Good night')
Here there are '
s instead of "
s.
Note that you cannot combine "
s and '
s. Examples of what you CANNOT do: print("peter songo')
or print('peter songo")
.
(
and a )
after print
, and your words go inside it.To show something on the screen to the person who is using your code, you will need to use a function called print
. Your teacher may teach you what functions are later. If you don't know, just look it up online. I recommend W3Schools for this and more.
Summarized for you: A function is multiple lines of code that can be used with one line. It is usually used when code has to be run multiple times.
A function requires parentheses - (
and )
. Inside the parentheses, you put in what you want to tell the function/lines of code. In this case, you want to tell it the words "peter songo".
The code all corrected:
print("peter songo")
or
print('peter songo')
This will put the words "peter songo" on the screen. Note that the words inside the "
s or '
s can be changed to your liking.
Hope this helped.
Upvotes: 0