0
a = input('a= ')
b = input('b= ')
c = input('c= ')

print(c<(a+b))
print(b<(a+c))
print(a<(b+c))

print (a)
print (b)
print (c)

while not(c<(a+b) and b<(a+c) and a<(b+c)):
    print('not a triangle.')
    a = input('a= ')
    b = input('b= ')
    c = input('c= ')
    




print('Loaded triangle a= {0}, b= {1}, c= {2}.'.format(a,b,c))

This is supposed to be a simple program for checking whether 3 sides make a triangle or not. But even the individual checks don't word (3,4,5), and some random combinations work (5,5,5)

1 Answers1

0

The input function returns a string. Everything you're doing here is working with strings. '3'+'4' gives you '34', not what you want. You need:

a = int(input('a= '))
b = int(input('b= '))
c = int(input('c= '))

Doing a few debug prints in there would have shown you this much quicker.

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30