I suggest it's just a simlpe tiny thing that has to be done to solve this but I simply can't figure it out! I hope anyone can help me.

Here's what I koppied from a learnbook for python.

>>> secret = 1337
>>> guess = 0
>>> l = 0
>>> while guess != secret:
... guess = input("Raten Sie: ")
... if guess < secret:
... print "zu klein"
... if guess > secret:
... print "zu groƟ"
... l = l + 1
...
Raten Sie: Traceback (most recent call last):
File "<input>", line 2, in <module>
EOFError: EOF when reading a line


At first I tried to change it for my use immidiately but this Error irritated me so I tried to use the original. But even that gives me the same Error concerning <input> in line 2!
I already tried different things to solve it myself but it didn't work out -,-

Use codetag and use english when you post in forums.
Try to run this script.
Maybe you have indentations problem when you type in IDLE.

secret = 1337
guess = 0
count = 0
#Help the user give number range.
print 'Guess s number it`s between 0 <-> 2000 '
while guess != secret:
    guess = input("Guess: ")
    if guess < secret:
        print "to small"
    elif guess > secret:
        print "to big"        
    count += 1

print 'You guessed the number in %s try' % count

Edited 6 Years Ago by snippsat: n/a

First of all: I'm sorry that my code is so messy because of the missing tags. I didn't realise it because I was in a hurry -,-
Anyways thanks for the fast supply but it still doesn't work. I typed everything in the way you discribed it but still the Error massage comes. Besides I don't type in IDLE only if I do programs for Gimp. I do this kind of coding in the python console.

Yes can be that he use python 3.
Then off course input()return a string.
input() in python 2 return an integer.
Here is a rewritten version for python 3

secret = 1337
guess = 0
count = 0
#Help the user give number range.
print ('Guess s number it`s between 0 <-> 2000 ')
while guess != secret:
    guess = int(input("Guess: "))
    if guess < secret:
        print ("to small")
    elif guess > secret:
        print ("to big")
    count += 1

print ('You guessed the number in %s try' % count)

Okay even after the second version for python 3 (actually I have python 2.6 but I though I'd still give it a try) the Error occures.

The first code should work fine for python 2.6
Here is a test from IDLE.

IDLE 2.6.5    
>>> secret = 1337
>>> guess = 0
>>> count = 0
>>> while guess != secret:
	guess = input("Guess: ")
	if guess < secret:
		print "to small"
	elif guess > secret:
		print "to big"
	count += 1

	
Guess: 500
to small
Guess: 5000
to big
Guess: 1337
>>>

Edited 6 Years Ago by snippsat: n/a

input() is the same as eval(raw_input())

try replacing input with raw_input()

raw_input return a string.
So my version for python 2.6 will not work with raw_input.
Can off course use int(raw_input(' ') to get it to return an integer.
Or chage the code later int(guess)

It`s alwayse best to use raw_input for python 2.x,this work same as input() python 3.x.
Both my code example should work fine,so maybe som problem with python installation for NekoChan.

Edited 6 Years Ago by snippsat: n/a

Yeah I guess it'S somewhitng with the program too, like snippsat already said. Maybe I forgot to install something or something just went wrong. -,-

This article has been dead for over six months. Start a new discussion instead.