PDA

View Full Version : how do I write an if then line in python?



exneo002
March 6th, 2008, 02:43 PM
I am new to programming and for practice I won't to write a basic commnand line game with true or false questions. How do I write an if then line for it?

Wybiral
March 6th, 2008, 02:45 PM
if check_something:
do_something()


What exactly do you mean?

Siph0n
March 6th, 2008, 02:55 PM
Does that help?


x = 10
if x == 10:
print 'X = 10'
elif x != 10:
print 'X != 10'

DemonDomen
March 6th, 2008, 05:03 PM
Here's the link to the tutorial:
LINK (http://docs.python.org/tut/node6.html)

exneo002
March 6th, 2008, 08:30 PM
I mean like if answer or input =x then output=true if input=else then output =false

imdano
March 6th, 2008, 08:40 PM
I think this is what you want, though I'm not exactly sure what's going on with the "input=else" thing.


if input == x:
output = True
else:
output = False

popch
March 6th, 2008, 08:55 PM
I am new to programming and for practice I won't to write a basic commnand line game with true or false questions. How do I write an if then line for it?


I mean like if answer or input =x then output=true if input=else then output =false

I do not think that the answers to the questions you ask here will be of much use to you.

As you say right at the beginning, you are new to programming, and your questions show it. I suggest that you first learn the basics of programming.

The 'stickies' of this forum contain very many and very broad hints on how to go about that. If you get stuck there, just come back and ask for clarification.