# python gives 2 different numbers instead of just 1

Page 1 of 1

## 2 Replies - 1354 Views - Last Post: 11 October 2012 - 08:47 AMRate Topic: //<![CDATA[ rating = new ipb.rating( 'topic_rate_', { url: 'http://www.dreamincode.net/forums/index.php?app=forums&module=ajax&section=topics&do=rateTopic&t=295206&amp;s=dfdc322ac579abb4a95c465fc96d8953&md5check=' + ipb.vars['secure_hash'], cur_rating: 0, rated: 0, allow_rate: 0, multi_rate: 1, show_rate_text: true } ); //]]>

### #1 Errk

Reputation: 0
• Posts: 6
• Joined: 03-October 12

# python gives 2 different numbers instead of just 1

Posted 11 October 2012 - 08:06 AM

```x=raw_input(">");
y=raw_input(">");
z=raw_input(">");

x=int(x);
y=int(y);
z=int(z);

if (x!=y!=z):
a=int(x)+int(y)+int(z);
printNow(a);

if (x==y and x!=z and y!=z):
b=int(x)+int(z)
printNow(B)/>;

if (x==z and x!=y and y!=z):
c=int(y)+int(x);
printNow(c);
```

so my assignment is to make a program that you enter 3 numbers and they have to be added together, but the none of the 3 numbers can be the same as each other. i was expecting for the bottom section
```if (x==z and x!=y and y!=z):
c=int(y)+int(x);
printNow(c);
```
to give me a 3 if x=1 y=2 and z=1, which it does but it gives me a 4 then a line below a 3. why is this? i dont know where the 4 comes from and i dont want it there. help would be appreciated!

Is This A Good Question/Topic? 0

## Replies To: python gives 2 different numbers instead of just 1

### #2 sepp2k

• D.I.C Lover

Reputation: 2226
• Posts: 3,429
• Joined: 21-June 11

## Re: python gives 2 different numbers instead of just 1

Posted 11 October 2012 - 08:22 AM

x != y != z means the same thing as x != y and y != z - it does not require that x != z.

So your problem is that it executes the first as well as the last if when x and z are equal.

### #3 Errk

Reputation: 0
• Posts: 6
• Joined: 03-October 12

## Re: python gives 2 different numbers instead of just 1

Posted 11 October 2012 - 08:47 AM

oh wow thank u so much, i was completely overlooking that, i fixed it to work perfect. you've been a lot of help thanks a ton