
EpiC BolT wrote:So I've just started python and to get a little better I decided to make a simple program that asks you questions and you can talk back to it. basically this is the only code I have so far (im a noob lol) <br><br>x=raw_input ('Enter Age Here: ')<br>print "That is nice, I am also " + x<br>y=raw_input ('where were you born?: ')<br>print "Thats pretty cool, How is it in " + y "I was born in Paraguay its really nice there"<br>raw_input ("press <enter> to end")<br><br>so every time I run this program to see if it works its telling me that i have an error and it is highlighting this part (i wull underline.<br>print "Thats pretty cool, How is it in " + y "I was born in Paraguay its really nice there"<br><br>what I want to make is that after you answer the question of where you were born the program says "thats pretty cool, how is it in (and then it says the place the person answered)" and then the program says it was born in Paraguay, but it doesnt seem to work. helppp pleaseeee. <br>basically i want it like this. (computer talking - user input - computer talking) in one sentence.<br><br>-- Thu Nov 24, 2011 2:55 pm --<br><br>I did notice that if i type the program like this it does do what i want it to <br>x=raw_input ('Enter Age Here: ')<br>print "That is nice, I am also " + x<br>y=raw_input ('where were you born?: ')<br>print "Thats pretty cool, How is it in " + y<br>print 'I was born in Paraguay its really nice there'<br>raw_input ("press <enter> to end")<br><br>but if i do that i have to put an extra print line under the "thats pretty cool,..." line and I would like it do all go on the same line.<br><br>-- Thu Nov 24, 2011 3:00 pm --<br><br>Also, sorry i keep posting stuff lol, lets say i ask a yes or no question in the program, is there a way to type code that would make the program act differently incase the use types yes or no.? I know theres a way to do this in Visual Basic .NET but I have no idea in python.


x=input('Enter Age Here: ') # use 'input' for integers, use 'raw_input' when saving strings.
if x==17: # If x equals 17 print statement.
print "That is nice, I am also %i" % x #use %i to substitute with x variable (integer)
if x!=17: # != means 'not equal to' so if x does not equal 17 print statement.
print "That's pretty cool!"
y=raw_input ('where were you born?: ')
# %s to substitute string for y variable
print "Thats pretty cool, How is it in %s, I was born in Paraguay its really nice there" % y
raw_input ("press <enter> to end")
x=input ('Enter Age Here: ') # use 'input' for integers
if x <10: # if x is less than 10, print
print 'You are young!'
elif x >=10: # if x is greater than or equal to 10, print.
print 'are you lying?'

x= int(raw_input("Enter your age here: ")
#Note if the do not enter a number an error will be made you must use try and throw to avoid this or put in other lines of code
# Also if you would like a float number like 10.0 instead of 10 you can do float(raw_input())


Users browsing this forum: No registered users and 0 guests