0

I know I should probably be able to figure this out on my own, but how do I simply make a code that changes somethings value depending on the input. This is my code:

a = False
c = input("do you want A to be positive or negative?\n")

if c== "Pos" or "pos":
    print("a switched to positive")
    a = True

if c== "Neg" or "neg":
    print("a switched to negative")
    a = False

It doesn't work though. How would I do this? Thanks!

Shawn
  • 1,232
  • 1
  • 14
  • 44

2 Answers2

0

Your python syntax is wrong. When checking in if condition, instead of

if c == "Pos" or "pos"

You should have,

if c == "Pos" or c == "pos"
Prakhar Londhe
  • 1,431
  • 1
  • 12
  • 26
0

One more solution:

a = False
c = input("do you want A to be positive or negative?\n")

if "pos" in c.lower():
    print("a switched to positive")
    a = True
elif "neg" in c.lower():
    print("a switched to negative")
    a = False

This will allow user to type "positive" or "negative" both in lower and caps. Also just "pos" and "neg" will be okay.

Neistow
  • 806
  • 1
  • 8
  • 20