-1

I am programming and I keep getting this: RESTART: C: This is my program:

import math

def PReading(Odometer):
     PLength = math.floor(len(Odometer) / 2)+1
     if Odometer[:PLength-1] == Odometer[:PLength:-1]:
          return True
     else:
          return False

for i in range(100000, 999999):
     SixDigit =str(i).zfill(6)
     if len(SixDigit) == 6:
          value1 = str(i).zfill(6)[2:]
          value2 = str(i+1).zfill(6)[1:]
          value3 = str(i+2).zfill(6)[1:5]
          value4 = str(i+3).zfill(6)
          if PReading(value1) \
          and PReading(value2) \
          and PReading(value3) \
          and PReading(value4):
               print ("Initial odemeter reading: " + str(i))

Thank you for your help!

  • 1
    Hey @BoopyPasta and welcome to StackOverflow - are you running this code using IDLE? When I execute it from the Terminal, I just get no output, so the `RESTART C:\...` is part of the IDLE output. If yes, please add this information, then I'll try to debug the code ;-) – Maurice Aug 27 '20 at 16:51
  • Is [this question](https://stackoverflow.com/questions/51959836/whenever-i-run-a-program-in-python-shell-i-get-a-line-that-says-restart-c/51959859) similar to yours? – Alex W Aug 27 '20 at 17:18
  • Please check out [How to Debug Small Programs](http://ericlippert.com/2014/03/05/how-to-debug-small-programs/) – Tomerikoo Aug 27 '20 at 17:23

1 Answers1

0

The only way I can reproduce your problem is by running the code in IDLE, so the output you're seeing is part of what IDLE prints out:

>>> 
============== RESTART: C:/Users/path/to/script/test.py ==============
>>> 

Running the code through a regular terminal, such as cmd under windows shows no output:

C:\Users\path\to\script>python test.py
C:\Users\path\to\script>

So you're seeing no output, because the print statement is never reached, meaning the if-condition is never true. If you provide us with a little more detail of what it is that you're trying to achieve in a new question we might be able to help you out - I tried to understand what you're doing. So far it just seems like weird string manipulation, without more context that's hard to understand.

P.S.: I recommend you take a look at the PEP8 Styleguide for Python, by convention we write variable and function names in snake_case and class names in PascalCase, which made your code a little hard to read. It's also good practice to add the if __name__ == "__main__": guard to any code you want to execute when your module is executed as a script.

Maurice
  • 11,482
  • 2
  • 25
  • 45