0

Assertions Python

My basic calculator project I'm doing to practice python is fine but i've added some assertions to the Multiply function and when trying to make an assertion error occur I can't.. What's wrong with my assertions. (Trying to show the second argument in the output if the first argument occurs) https://code.sololearn.com/cMwYU4G32wZe/?ref=app

31st Mar 2020, 12:47 AM
Christian Jacob O'Neill
Christian Jacob O'Neill - avatar
3 Respuestas
+ 2
The problem is that you are never reaching the multiply part. Your code is only handling quit and add part. In python every non empty string is evaluated as True in a conditional statement (if,elif) user_input == "add" or "+" or "Add": Now imagine user input is "*": user_input == "add" is False. But "+" is TRUE because it's a non empty string and we run the add code even when user input is * !!! You should read that condition like this: If user_input == "add" is True or "+" is True or "Add" is True: # do stuff Your conditions(all) should be something like this: if user_input == "add" or user_input=="+" or user_input=="Add"
31st Mar 2020, 2:28 AM
Kevin ★
- 2
bleh
11th Aug 2020, 12:44 AM
Seanneol Ebneazer Anan
Seanneol Ebneazer Anan - avatar
- 3
tolong aku dulu..... apa ni moonton
11th Aug 2020, 12:45 AM
Seanneol Ebneazer Anan
Seanneol Ebneazer Anan - avatar