[Minor Bug] PygLatin: Input! doesn't work with input()


Link: https://www.codecademy.com/courses/python-beginner-2W5v7/0/3?curriculum_id=4f89dab3d788890003000096

This lesson only works with raw_input(). Shouldn't it also work with input() now?

Doesn't work:

print 'Welcome to the Pig Latin Translator!'
original = input("Enter a word:")

# Start coding here!


print 'Welcome to the Pig Latin Translator!'
original = raw_input("Enter a word:")

# Start coding here!


In python 2.x,

input() takes an input and evaluates it.
so the input should be valid otherwise it will throw an error.

raw_input() simply takes user input as string.

in python 3.x
raw_input() has been replaced by input()

a good discussion to check..



Yeah, if this lesson really wants to be accurate shouldn't it be

print 'Welcome to the Pig Latin Translator!'
original = str(input("Enter a word:"))



Nope,converting an error to a string ?
as input() will evaluate your input ,if it does not found it correct, then it won't take it as valid expression and throws an error.

solution is simple..
Users have to enter input with quotes then It won't throw any error. (Try this but as in lesson we have to use raw_input(), it still gives you an error.)

so raw_input() perfectly fits here and saves us from this trouble!


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.