timothy ford
timothy ford

Reputation: 9

EOF when reading a line

This is error is point towards this line of code:

s = str(input("Enter the String to be reversed:"))

def print_backward(string):
    if len(string) == 0:
        return string
    else:
        return print_backward(string[1:]) + string[0]

s = str(input("Enter the String to be reversed:"))
print(print_backward(s))

Upvotes: 0

Views: 154

Answers (1)

Aidan H
Aidan H

Reputation: 122

This appears to work perfectly. Maybe include something like this to make input work on Python 2 and 3.

try:
    input = raw_input
except NameError:
    pass

Upvotes: 1

Related Questions