Why is my program suddenly not working for no reason?

  1. When this kind of thing happens, you have to think through how likely your assumptions are. Unchanged programs that worked before don't stop working without some outside change that affects them - things like updated Python verson or liabraries used can do this. I don't think this is likely the case here, though, because the error is about something that has always been the same in Python: you can only compare strings with strings, and since input always returns a string, your code would never have worked without the quotes.

  2. Thanks for the reply, but I figured it out. I should have been running it using Python3, not Python. It works just fine when I run it using python3 ./Cipher.py.

  3. Yes, you were running it using a Python 2 interpreter where input() acts like eval(input()) and tries to interpret what you enter as code.

  4. Personally, I have put an '''alias python=python3''' in my .zshrc file. Not sure if there's some edge case that will one day bite me, but so far in the past few years it has only been a boon to my quality-of-life.

Leave a Reply

Your email address will not be published. Required fields are marked *

Author: admin