0

Command prompt

I tried to run this python code:

#two brown number are an ordered pair in the form (m; n) such that n!+1=m^2
from math import factorial as fact
m=2
n=2
for i in range(10**2): # range of values to check
    # checks current values and changes them according to results
    if (fact(n)+1)==m**2:
        print(m,n)
        m+=1
        n+=1
    elif (fact(n)+1)<m**2:
        n+=1
    elif (fact(n)+1)>m**2:
        m+=1

from the command prompt but it showed me the message on the image above, even though I already installed python 3.9 from the official website.

The python stuff I installed

Anyone knows how to fix this or do I have to reinstall python from the Microsoft Store?

  • 1
    The image is not visible – Armaggheddon Aug 26 '21 at 10:57
  • [Please do not upload images of code/errors when asking a question](https://meta.stackoverflow.com/q/285551). Edit your question to include the relevant information as text. – Alex Aug 26 '21 at 11:00
  • 1
    You should use the full python installation path or try with `py program.py` – Armaggheddon Aug 26 '21 at 11:01
  • why are you running `python brown scriptname.py` try using `python scriptname.py`, just `scriptname.py` or `py scriptname.py` – Bendik Knapstad Aug 26 '21 at 11:03
  • If you installed cpython did you tick the PATH box. It's also unticked in the image ... https://docs.python.org/3/using/windows.html – jwal Aug 26 '21 at 11:03

2 Answers2

1

Rename your file containing the code. There must not be spaces and then use the command:

python3 filename.py

Piero
  • 404
  • 3
  • 7
  • 22
1

To call files with spaces use the quotation marks around them. python ".\brown numbers.py"

Generally, it is better to avoid spaces in files names, but sometimes it is unavoidable. In such situations you must explicitly tell Python what is the full file name.

To check if Python is installed correctly run: python --version

program
  • 21
  • 4