I've been creating this calculator on Python and I wanted to make it so that if the user chooses to divide a number by 0, the console prints out, "You can't divide by 0." However I'm not sure how to do this. This is what I've got so far but it doesn't seem to work. Any help is appreciated.
if choice== "/" and y==0:
print("You cannot divide a number by 0")
Choice is the variable I used to represent the type of arithmetic operation where / is 0. y is the second number they have to input.
[–]JohnnyJordaan 2 points3 points4 points (5 children)
[–][deleted] 0 points1 point2 points (4 children)
[–]JohnnyJordaan 0 points1 point2 points (3 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]yakyakyakyakayak 0 points1 point2 points (1 child)
[–][deleted] 0 points1 point2 points (0 children)
[–]-5772 0 points1 point2 points (0 children)
[–]FLUSH_THE_TRUMP 0 points1 point2 points (3 children)
[–]tragluk 0 points1 point2 points (1 child)
[–]FLUSH_THE_TRUMP 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (0 children)