Hello,
On Windows, I installed Anaconda and Pycharm. From reading the screen, I tried typing in the first program and running it, but got the following error. I created a file in the same path with text. When I ran the prog, I was not sure if I needed to add the full path or not when responding to the interactive prompt, so I added the full path in a var.
See the code, and the error message below.
----------------------------------------------------------------------------------------
file: greg_learning.py
path: c:\Users\Greg Makowski\PycharmProjects\training\
description: CloudXLab, Python course
----------------------------------------------------------------------------------------
infile = ‘C:/Users/Greg Makowski/PycharmProjects/training/text_file.txt’
name = input(‘Enter_file:’)
handle = open(infile, ‘r’)
text = handle.read()
words = text.split()
counts = dict()
for word in words:
counts[word] = counts.get(word, 0) + 1
bigcount = None
bigword = None
for word, count in counts.items():
if bigcount is None or count > bigcount:
bigword = word
bigcount = count
print(bigword + “\t” + str(bigcount))
----------------------------------------------------------------------------------------
C:\ProgramData\Anaconda3\python.exe “C:/Users/Greg Makowski/PycharmProjects/training/greg_learning.py”
Traceback (most recent call last):
File “C:/Users/Greg Makowski/PycharmProjects/training/greg_learning.py”, line 10, in
text = handle.read()
File “C:\ProgramData\Anaconda3\lib\encodings\cp1252.py”, line 23, in decode
return codecs.charmap_decode(input,self.errors,decoding_table)[0]
UnicodeDecodeError: ‘charmap’ codec can’t decode byte 0x9d in position 378: character maps to
Process finished with exit code 1