Ive been reading up on while Loops while learning python. The following works without error, however if I insert 16 as value, I get
Insert numbers only
Your weight is 16 lbs
This is not correct
while True:
weight_input = raw_input ("Add your weight: ")+(" lbs")
try:
val = int(weight_input)
except ValueError:
print("Insert numbers only")
print("Your weight is " + weight_input + "!")
What am I missing ? I am trying to print out weight and if value = anything other then a integer then send error.
UPDATE
Decided on using tables with above . I get a error adding "lbs" Any help? print(tabulate([[weight_input]+"lbs"], tablefmt='pipe', headers=('Weight')))
weight_inputis"16 lbs". That's not a valid integer