-6

I made my first python program of hello world.

Every time i save it,it cannot be open in the program.

And the program just blink and flashes away.

I read few line 'invalid syntax'.

here what I WROTE:

>>>print('hello world')

then i saved it as p.py and try to run it on program and zilch.

U13-Forward
  • 69,221
  • 14
  • 89
  • 114
  • How are you running your program? Is it from the command line? If the program "just blink and flashes away", it sounds like windows. Try opening a command prompt (start->run->cmd), navigate to the folder that contains your file, and type `python p.py`. – pault Jan 10 '18 at 17:47
  • Welcome to Stack Overflow. People here generally do want to help you, but that would require a little bit more information so that they can understand your issue. You can start by reading [How do I ask a good question?](https://stackoverflow.com/help/how-to-ask) and then try to provide a [mcve]. Good luck. – pault Jan 10 '18 at 20:53

3 Answers3

0

I have a feeling you are reading the book 'The self taught programmer'? What you need to do is realize the shell and the notepad are two different things.

Do this.

Open up the IDLE shell, but then go to the file-new-new file

This should open a new window. Now this window, simply put the Print("Hello, taxation is theft"). Now, save this window, as whatever you want. Now, in the same window, with both the shell open, and this new window, click F5 or run 'run module'.

You'll see what you made in the notepad will run on the shell window. It will only run once. The next step is to practice running it 5 times, then 100 times. You'll get there bud.

Dharman
  • 30,962
  • 25
  • 85
  • 135
0

While saving .py file you must have beeen saving it as it is, containing other whitespaces and charater like ">>". remove ">>> " fr

  • 2
    Welcome to SO! This is a very old question (and also not a very good one) with a couple of answers. Ask yourself: Is your additional answer really helpful? Also, your answer is hard to understand. What do you mean by ">>". remove ">>> " fr"? I recommend reading [How do I write a good answer?](https://stackoverflow.com/help/how-to-answer) – Timus Oct 14 '20 at 11:18
-2

In python 2.7 print looks like this:

print "hello world"

In python 3 it looks like this:

print( "hello world" )

Run your code with python3:

python3 p.py
PatB
  • 415
  • 1
  • 5
  • 13