PygLatin 3.Input! explanation needed


#1

Instructions:
On line 4, use raw_input("Enter a word:") to ask the user to enter a word. Save the results of raw_input() in a variable called original.
Click Save & Submit Code
Type a word in the console window and press Enter (or Return).
?

I now know the correct way to enter this information is

print 'Welcome to the Pig Latin Translator!'

Start coding here!

original = raw_input("Enter a word:")

But I'm confused because in my head I feel like it should be:

print 'Welcome to the Pig Latin Translator!'

Start coding here!

raw_input("Enter a word:")
original = raw_input()

My reasoning is that it doesnt make sense for me to assign a variable to something that at that point hasnt been created yet (the raw input itself). Can anybody explain why we do it one way and not the other in a way that would make sense to me? I am VERY new to this, and would really appreciate the input.


#2

raw_input is function so if you do original = raw_input() it expect some arguments in (), you are trying to use raw_input like variable

you can do this

input = raw_input("Something: ")
original = input

hope I understood your confusion and explained it


#3

raw_input() function reads a line from input (i.e. the user) and returns a string by stripping a trailing newline.
If the prompt argument is present, it is written to standard output without a trailing newline.
The syntax is for your code :

original = raw_input("Enter a word:")
print original

example :


#4

you did, thank you for clearing that up for me! :grin:


#5

I got tripped up on the instruction “Save the results of raw_input() in a variable called original .”

I think I understand this a little better.