Discuss Scratch
- Discussion Forums
- » Advanced Topics
- » EOF Error
- mbrick2
-
Scratcher
1000+ posts
EOF Error
Here is my code:
it outputs
What am I doing wrong??
# setup keyProb = [] result = [] key = ['apple','banana','hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n world\n') inp = input() r1 = 0 r2 = 0 for x in range (len(key)): print('Loading') for i in len(inp): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('')
Traceback (most recent call last): File "./prog.py", line 8, in <module> EOFError: EOF when reading a line
- MagicCrayon9342
-
Scratcher
1000+ posts
EOF Error
EOF commonly referred to as “End of File” usually has something to do with the ending of a loop or function.
- MagicCrayon9342
-
Scratcher
1000+ posts
EOF Error
These are the issues with your code:
some being cleanliness and PEP standards but the last one makes sense.

some being cleanliness and PEP standards but the last one makes sense.

Last edited by MagicCrayon9342 (Dec. 15, 2021 21:45:11)
- mbrick2
-
Scratcher
1000+ posts
EOF Error
These are the issues with your code:Thanks.
some being cleanliness and PEP standards but the last one makes sense.
Also what website did you use for that??
- mbrick2
-
Scratcher
1000+ posts
EOF Error
# setup keyProb = [] result = [] key = ['apple', 'banana', 'hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n hello\n world\n') inp = 'appel' #input() r1 = 0 r2 = 0 for x in range (len(key)): print('Loading') for x in (len(inp)): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('\n')
Traceback (most recent call last): File "./prog.py", line 14, in <module> TypeError: 'int' object is not iterable
- MagicCrayon9342
-
Scratcher
1000+ posts
EOF Error
Our encounter with for-loops introduced the term iterable - an object that can be “iterated over”, such as in a for-loop. Definition: An iterable is any Python object capable of returning its members one at a time, permitting it to be iterated over in a for-loop.
- god286
-
Scratcher
1000+ posts
EOF Error
# setup keyProb = [] result = [] key = ['apple', 'banana', 'hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n hello\n world\n') inp = 'appel' #input() r1 = 0 r2 = 0 for x in range(len(key)): print('Loading') for x in range(len(inp)): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('\n')
Last edited by god286 (Dec. 15, 2021 23:31:49)
- mbrick2
-
Scratcher
1000+ posts
EOF Error
# setup
keyProb =
result =
key =
equalLetters = 0
# run code
print('Please input one of the following \n apple \n banana\n hello\n world\n')
inp = ‘appel’
#input()
r1 = 0
r2 = 0
for x in range(len(key)):
print('Loading')
for x in range(len(inp)):
keyProb.append(' ')
if key[r1] == inp:
keyProb = ‘#’
equalLetters = equalLetters + 1
r2 = r2 + 1
r2 = 1
result.append(equalLetters)
r1 = r1 + 1
keyProb.clear()
print('\n')
Traceback (most recent call last): File "./prog.py", line 16, in <module> TypeError: 'int' object is not subscriptable
- Chiroyce
-
Scratcher
1000+ posts
EOF Error
Traceback (most recent call last):Wait i'm getting this?!
File “./prog.py”, line 8, in <module>
EOFError: EOF when reading a line
Traceback (most recent call last):
File "/Users/Chiroyce/Downloads/test.py", line 13, in <module>
for i in len(inp):
TypeError: 'int' object is not iterable
Looks like the line
for i in len(inp):
for i in range(len(inp)):
- mbrick2
-
Scratcher
1000+ posts
EOF Error
thanks
Traceback (most recent call last):Wait i'm getting this?!
File “./prog.py”, line 8, in <module>
EOFError: EOF when reading a lineTraceback (most recent call last):
File "/Users/Chiroyce/Downloads/test.py", line 13, in <module>
for i in len(inp):
TypeError: 'int' object is not iterable
Looks like the lineshould befor i in len(inp):for i in range(len(inp)):
- Greg8128
-
Scratcher
500+ posts
EOF Error
Here is my code:What is this code supposed to do? For all we know, it IS supposed to produce an EOF errorit outputs# setup keyProb = [] result = [] key = ['apple','banana','hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n world\n') inp = input() r1 = 0 r2 = 0 for x in range (len(key)): print('Loading') for i in len(inp): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('')What am I doing wrong??Traceback (most recent call last): File "./prog.py", line 8, in <module> EOFError: EOF when reading a line

- mbrick2
-
Scratcher
1000+ posts
EOF Error
It is supposed to compare the input with the keywords in numbersHere is my code:What is this code supposed to do? For all we know, it IS supposed to produce an EOF errorit outputs# setup keyProb = [] result = [] key = ['apple','banana','hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n world\n') inp = input() r1 = 0 r2 = 0 for x in range (len(key)): print('Loading') for i in len(inp): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('')What am I doing wrong??Traceback (most recent call last): File "./prog.py", line 8, in <module> EOFError: EOF when reading a line
- Greg8128
-
Scratcher
500+ posts
EOF Error
In what way?It is supposed to compare the input with the keywords in numbersHere is my code:What is this code supposed to do? For all we know, it IS supposed to produce an EOF errorit outputs# setup keyProb = [] result = [] key = ['apple','banana','hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n world\n') inp = input() r1 = 0 r2 = 0 for x in range (len(key)): print('Loading') for i in len(inp): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('')What am I doing wrong??Traceback (most recent call last): File "./prog.py", line 8, in <module> EOFError: EOF when reading a line
Try describing the function in such a way that someone else would be able to create it, and have it work exactly the way you want, using only the description
- mbrick2
-
Scratcher
1000+ posts
EOF Error
finds similarities inbetween input and keywords.In what way?It is supposed to compare the input with the keywords in numbersHere is my code:What is this code supposed to do? For all we know, it IS supposed to produce an EOF errorit outputs# setup keyProb = [] result = [] key = ['apple','banana','hello', 'world'] equalLetters = 0 # run code print('Please input one of the following \n apple \n banana\n world\n') inp = input() r1 = 0 r2 = 0 for x in range (len(key)): print('Loading') for i in len(inp): keyProb.append(' ') if key[r1[r2]] == inp[r2]: keyProb[len(keyProb)] = '#' equalLetters = equalLetters + 1 r2 = r2 + 1 r2 = 1 result.append(equalLetters) r1 = r1 + 1 keyProb.clear() print('')What am I doing wrong??Traceback (most recent call last): File "./prog.py", line 8, in <module> EOFError: EOF when reading a line
Try describing the function in such a way that someone else would be able to create it, and have it work exactly the way you want, using only the description
https://scratch.mit.edu/projects/617626821/
- Greg8128
-
Scratcher
500+ posts
EOF Error
finds similarities inbetween input and keywords.I assume that you want to do the following:
https://scratch.mit.edu/projects/617626821/
Create a comparison test “cmp” which takes 2 strings and returns in how many positions they both have a letter and the letters match
Given an input string, run “cmp” on the string and each of several other strings
In Haskell, you would write this as:
strTest xs ys = length . filter id $ zipWith (==) xs ys
The Python equivalent is:
str_test = lambda xs, ys: sum(map(operator.eq, xs, ys))
- Discussion Forums
- » Advanced Topics
-
» EOF Error




