On remplace les if en elif pour avoir un résultat correct

Signed-off-by: Yohann D'ANELLO <ynerant@crans.org>
This commit is contained in:
Yohann D'ANELLO 2021-01-28 14:47:20 +01:00
parent be7efbbfa7
commit e8fc6d0816
Signed by: ynerant
GPG Key ID: 3A75C55819C8CF85
1 changed files with 6 additions and 6 deletions

12
main.py
View File

@ -85,17 +85,17 @@ def calcul(left: int, right: int, res: int, operation='+'):
if operation in ['+', 'add', 'sum']:
result = left + right
if operation in ['-', 'sub']:
elif operation in ['-', 'sub']:
result = left - right
if operation in ['*', 'mul', 'prod']:
elif operation in ['*', 'mul', 'prod']:
result = left * right
if operation in ['/', 'div']:
elif operation in ['/', 'div']:
result = left / right
if operation in ['&', 'and']:
elif operation in ['&', 'and']:
result = left & right
if operation in ['|', 'or']:
elif operation in ['|', 'or']:
result = left | right
if operation in ['^', 'xor']:
elif operation in ['^', 'xor']:
result = left ^ right
else:
result = left % right