0

Fairly new to Python here, and working on Exercise 23 from Learn Python the Hard Way.

I'm having an issue running this code in Git Bash on a Windows comp, and I'm getting an error. Been racking my brain, wondering if it's my code or setting on my computer with the unicode characters.

Here is my code

import sys
script, input_encoding, error = sys.argv


def main(language_file, encoding, errors):
    line = language_file.readline()

    if line:
        print_line(line, encoding, errors)
        return main(language_file, encoding, errors)


def print_line(line, encoding, errors):
    next_lang = line.strip()
    raw_bytes = next_lang.encode(encoding, errors=errors)
    cooked_string = raw_bytes.decode(encoding, errors=errors)

    print(raw_bytes, "<===>", cooked_string)


languages = open("languages.txt", encoding="utf-8")

main(languages, input_encoding, error)

And here is the response I'm getting when running the program in Git Bash with the command Response Code When Running Ex 23

Ron A
  • 15
  • 3
  • The link to the languages.txt file: https://learnpythonthehardway.org/python3/languages.txt – Ron A Oct 14 '22 at 22:58
  • This is a Windows problem, not a problem with the code. I will try to find the appropriate canonical. In the mean time, it will be helpful to indicate your Python version. – Karl Knechtel Oct 14 '22 at 23:05
  • 2
    Please see Voy's answer [here](/questions/27092833). Also, [Please do not upload images of code/data/errors when asking a question.](//meta.stackoverflow.com/q/285551) – Karl Knechtel Oct 14 '22 at 23:09
  • Thanks @KarlKnechtel. New to StackOverflow as well so I'll keep in mind in the future not to upload images. I appreciate the help. – Ron A Oct 15 '22 at 01:31
  • I found a better duplicate (and added to my saved list). – Karl Knechtel Oct 15 '22 at 01:36

0 Answers0