0

all of the print statements in the while loop are giving me errors i have no idea why it looks ok on paper so if you have anything let me know im thinking maybe its a problem with the values and the print statement both in one while loop

w = False a = False v = False if action == "w": w = True if action == "v": v = True if action == "a": a = True while w == True: volts = input("Volts: ") amperes = input("Amps: ") volts = int(volts) amperes = int(amperes) print("Your Watts Are " + volts * amperes) w = False while v == True: watts = input("Watts: ") amperes = input("Amps: ") watts = int(watts) amperes = int(amperes) print("Your Volts Are " + watts // amperes) v == False while a == True: watts = input("Watts: ") volts = input("Volts: ") watts = int(watts) amperes = int(amperes) print("Your Amps Are " + watts // volts) a = False end = input("Press Enter to exit") 
2
  • If you want to concatenate an int/float with a string, you need to convert it first, e.g. print("Your Amps Are " + str(watts // volts)) Commented Mar 16, 2020 at 2:56
  • what is action ? Commented Mar 16, 2020 at 3:17

1 Answer 1

3

When trying to concatenate a string with an int or float, python will raise a TypeError. You first need to convert the numeric value to a string, for example:

print("Your Amps Are " + str(watts // volts)) 

Alternatively, you may use string formatting:

print("Your Amps Are {}".format(watts // volts)) 

or, in python > 3.6:

print(f"Your Amps Are {watts // volts}") 
Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.