Przepraszam za niezbyt dokładny tytuł, po prostu nie znalazłem lepszych słów. Do rzeczy:
Uczę się pythona, kodziłem używając interpreterów online, jednak coś mi się kaszaniło. Wyskakiwał błąd którego nie rozumiałem, więc ściągnąłem Pythona i IDE na dysk. Kod, wcześniej niekompilowany przez interpretatory online, zadziałał. Niby po sprawie, ale stwierdziłem, że sprawę przydałoby się wyjaśnić - ot, ku przyszłości. Nieszczęsny kod w skróconej wersji to:
# My first program written in Python - Pig Latin Translator
# lists
numberList = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
specChaList = ['!', '"', '#', '$', '%', '&', '(', ')', '*', '+', ',', '/', ':', ';', '<', '=', '>', '?', '@', '{', '|', '}', '~', '#', '^', ']', '[', '-']
# strings
welcomeText = 'Welcome in Pig Latin Translator! The program is a language game, where you move the first letter of the word to the end and add "ay." So "Python" becomes "ythonpay." Have fun!'
requestText1 = 'To start the game type some English word: '
requestText2 = 'Try again: '
foundNumberText = 'Hm... I am not quite sure, but in English language there is not any word which contains numbers inside, is not?'
foundSpecChaText = 'I know that I am just a stupid program, but even I know that there is not any word in English dictionary which contains special signs inside'
# input a word
word = input(requestText1)
#main loop
while True:
# boolean
foundNumber = False
foundSpecCha = False
# checking if typed word do not contain any number inside
for n in range (0, len(numberList)):
for x in range (0, len(word)):
if(word[x] == numberList[n]):
print("Found a number!")
foundNumber = True
break
# checking if typed word do not contain any special characters inside
lastIndex = len(specChaList)
for n in range (0, lastIndex):
for x in range (0, len(word)):
if(word[x] == specChaList[n]):
print("Found a special character!")
foundSpecCha = True
break
# execute
if(foundNumber):
print(foundNumberText)
word = input(requestText2)
elif(foundSpecCha):
print(foundSpecChaText)
word = input(requestText2)
else:
print('We are the {} who say "{}!"'.format('knights', 'Ni'))
print('You typed {}! Give me a moment, I will translate it.'.format(word))
print('Take it...\nMove there...\nAnd add that there...\nMake sure...\n')
translatedWord = word[1:] + word[0] + 'ay'
print('...Voila! {}'.format(translatedWord))
break
Treść błędu z ideone.com:
Traceback (most recent call last):
File "./prog.py", line 15, in <module>
EOFError: EOF when reading a line
Proszę o wyjaśnienie