Python raw_input causes error with no chance to input anything


#1

Hello everyone,

I just started to use codeacademy and to take the python course. At part 2.15, the command ‘raw_input’ is needed for the first time. The correct code for this step should be:

name = raw_input("What is your name?")
quest = raw_input("What is your quest?")
color = raw_input("What is your favorite color?")

print "Ah, so your name is %s, your quest is %s " \
"and your favorite color is %s." % (name, quest, color)

When I execute the code, I get the following error:

What is your name?What is your quest?What is your favorite color?Ah, so your name is SCT, your quest is if type(error) == ValueError: and your favorite color is 	return "Make sure to use a lowercase \"s\" with \%s. Python told us about the following error: " + str(error).

I don’t even get a chance to enter anything. I tried this with FF and IE on 2 different computers. I also tried

name = raw_input('Enter something: ')
print (name)

which cause the following output

Enter something: SCT

The cursor is located in the next line without being able to enter anything. I read that raw_input is simply input in python 3. So I tried

name = input('Enter something: ')
print (name)
Enter something: Traceback (most recent call last):
  File "python", line 1, in <module>
  File "<string>", line 1, in <module>
NameError: name 'SCT' is not defined

Is this a bug or am I doing something wrong?

Thanks a lot in advance!

Andreas


#2

Do you enter your name, quest and favorite color in the prompt? You should (or at least type something into the prompt)


#3

That’s the problem: It won’t let me type anything at the prompt. When I use this code

name = raw_input('Enter something: ')
print (name)

It prints "Enter something: " into the output window. About two seconds later, it adds “SCT” and a newline so that the prompt is in the next line. There is no way to enter anything…


#4

please provide exercise url so i can actually run the code in the lesson


#5

https://www.codecademy.com/courses/learn-python/lessons/strings--console-output/exercises/string-formatting-with--part--1


#6

unable to reproduce problem, i can enter something into the prompt and i can’t retake the exercise.

you can try this:

try: 
    name = raw_input("What is your name?")
    quest = raw_input("What is your quest?")
    color = raw_input("What is your favorite color?")
except:
  name = "your name"
  quest = "your quest"
  color = "color"

print "Ah, so your name is %s, your quest is %s " \
"and your favorite color is %s." % (name, quest, color)

otherwise please show me a screenshot


#7

I copy/pasted your code into the browser. Please find attached a screenshot of the result.


#8

weird, try refreshing the page. Whatever the problem was, it should be over now (for other people it was)

I can’t reproduce the problem that the prompts are automatically entered, i have to manual enter something


#9

Yes, weird. I just restarted FF and executed the code again: same result. I also tried again in IE with the exact same result.


#10

other people did solve the problem, its not something i an fix from here given there is nothing wrong with your code


#11

Well, I tried it 5 time in a row with code that is definitely correct in IE. When I hit the Run-button, the output changes to “What is your name?” for about half a second, then the rest of the text from the screenshot occours without me doing anything. The Run-button changes to a busy icon and switches back to “Run” after exactly 30 seconds. Since other people are having the same issue and I can reproduce it in different browsers on different machines, I suppose it’s a server-side error. I don’t see anything I can do to fix it. I got past this problem in the exercise by executing

name = "Name"
quest = "Quest"
color = "Color"

print "Ah, so your name is %s, your quest is %s, " \
"and your favorite color is %s." % (name, quest, color)

But the first exercise of “Conditionals & Control Flow” failed like this:

I just hit the Run-button, nothing else…


#12

I went back to the page from which I snapped the screen and it acually let me enter something at the end. When I type “r” and hit enter, it replied with the correct phrase:

But it still took the Run-button 30 seconds to switch back to “Run” and the Next-button is still greyed out.


#13

Well, just doing nothing for a few days fixed it, since now it’t working.

@stetim94: Did you change anything? It’s quite strange that all of a sudden it works…


#14

well, this was a bug on codecademy sites, yes the engineers fixed it


#15

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