Jump to content

[Python] if input matches input first entered then.

Go to solution Solved by werto165,
3 minutes ago, WillLTT said:

well now it will always be works, beacuse i only ask it

if example1 then

it does not check if the two inputs in the code below matches

hotdog.PNG

input1 = input("Please enter var1")
input2 = input("Please enter var2")

if(input1 == input2):
    print("hello world")
else:
    print("goodbye world")

 

...

I googled for a while and i could not find any help at this.

What im trying todo:

first enter input with

example = input()

 

then a another input THEN check if that input matches first input.

if it does run a command..

if it does NOT run a different command

Link to post
Share on other sites

 

if(bool):

    run command

else:

    different command

 

?

 

or

 

if(bool1 and bool2):

    run command

else:

    different command

 

?

 

input1 =True
input2 =False

if(input1 and input2):
    print("hello world")
else:
    print("goodbye world")

OR: 

 

input1 = input("Please enter var1")
input2 = input("Please enter var2")

if(input1 == input2):
    print("hello world")
else:
    print("goodbye world")

 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

11 minutes ago, werto165 said:

--snip--

that wount work, example:

example = input()
if (example)
	print("WORKS")

else:
	exit()

does not matter if the IF has space between it and (example)

 

hotdog.PNG

Link to post
Share on other sites

Just now, WillLTT said:

that wount work, example:


example = input()
if(example)
	print("WORKS")

else:
	exit()

 

 

hotdog.PNG

that's checking if example is True. so a boolean operation. You are only comparing one thing there; boolean check to see if it is True, you need another variable to check it against. 

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

you are also missing a colon (:)

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

3 minutes ago, werto165 said:

you are also missing a colon (:)

well now it will always be works, beacuse i only ask it

if example1 then

it does not check if the two inputs in the code below matches

hotdog.PNG

Link to post
Share on other sites

3 minutes ago, WillLTT said:

well now it will always be works, beacuse i only ask it

if example1 then

it does not check if the two inputs in the code below matches

hotdog.PNG

input1 = input("Please enter var1")
input2 = input("Please enter var2")

if(input1 == input2):
    print("hello world")
else:
    print("goodbye world")

 

...

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

Just now, WillLTT said:

sorry for being bad at this.

But thanks for helping ?

Sorry of me :D It was just that I did on my first post ;)

CPU: Intel 3570 GPUs: Nvidia GTX 660Ti Case: Fractal design Define R4  Storage: 1TB WD Caviar Black & 240GB Hyper X 3k SSD Sound: Custom One Pros Keyboard: Ducky Shine 4 Mouse: Logitech G500

 

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×