Can someone please help me? I'm brand new to programming and I'm stuck on problem set 0... This is the closest I've come so far: raw_input('Enter your date of birth:') ans = DOB raw_input('Enter your last name:') ans = name print name + DOB It prompts for my DOB, returns it, then stops. Why doesn't it prompt for my name?
Hm. I'm not entirely sure what that code is doing per se. You want to put the result of raw_input into the appropriate variable: DOB = raw_input('Enter your date of birth:') name = raw_input('Enter your last name:') print name + DOB That should work, as raw_input will put the result of what the user types into the DOB variable, and then the second time into the name variable. Then you print both.
raw_input() is a function. A function is a block of code that does a task. When a function finishes, it can return a value. In this case you want to assign the return value to a variable. Assignment is done with a single equal sign. DOB = raw_input('Enter your date of birth:') The 'Enter your...' string is passed into the function. In your code, you were calling the raw_input() function, but then trying to assign what was at that point an undefined variable DOB to ans. In programming, the value of the right side of the "=" is assigned to the left side.
That's what I tried first! It only asks for my birthday, and then doesn't even print it to the screen...
oops! never mind... i just hadn't figured out how to use idle properly yet. got it. thank you :)
Good to hear you got it figured out :)
(Might want to give rsmith a medal above if he was helpful ;) )
raw_input() returns a value so assign it to your variable . DOB = raw_input('say somethin')
Join our real-time social learning platform and learn together with your friends!