Python Forum
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
my code not working
#1
I was messing around in python and I remembered something which my Maths teacher taught me and I turned it into code. So here it is:

TriSide1 = input('measure of 1st side of Triangle - ')
TriSide2 = input('measure of 2nd side of Triangle - ')
TriSide3 = input('measure of 3rd side of Triangle - ' )
if ((TriSide1 + TriSide2) > TriSide3) and ((TriSide2 + TriSide3) > TriSide1) and ((TriSide3 + TriSide1) > TriSide2):
  print('A proper triangle is formed')
else:
  print('A proper triangle is not formed') 
The problem is that it is not working as it is supposed to do as you can see from the code and the output that you will get. (I entered numbers 2,3,4 and it says that a proper triangle is not formed)only when I entered the same numbers did the code say that a proper triangle is formed. Is it because I am using online python sites and not the downloaded one? or is it a bug? I wish someone can help me out. Wall Think
Reply
#2
input() will return str. you need to convert that to int/float using int() or float() function
If you can't explain it to a six year old, you don't understand it yourself, Albert Einstein
How to Ask Questions The Smart Way: link and another link
Create MCV example
Debug small programs

Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  New to Python - Not sure why this code isn't working - Any help appreciated TheGreatNinx 4 908 Jul-22-2023, 10:21 PM
Last Post: Pedroski55
  code not working when executed from flask app ThomasDC 1 834 Jul-18-2023, 07:16 AM
Last Post: ThomasDC
  I am new to python and Could someone please explain how this below code is working? kartheekdas 2 971 Dec-19-2022, 05:24 PM
Last Post: kartheekdas
Exclamation My code is not working as I expected and I don't know why! Marinho 4 1,030 Oct-13-2022, 08:09 PM
Last Post: deanhystad
  My Code isn't working... End3r 4 1,863 Mar-21-2022, 10:12 AM
Last Post: End3r
  I don't undestand why my code isn't working. RuyCab 2 1,956 Jun-17-2021, 03:06 PM
Last Post: RuyCab
  code is not working , can anybody help? RandomPerson69 4 2,848 Mar-22-2021, 04:24 PM
Last Post: deanhystad
  Short code for EventGhost not working Patricia 8 3,584 Feb-09-2021, 07:49 PM
Last Post: Patricia
  Code no longer working yk303 14 9,947 Dec-21-2020, 10:58 PM
Last Post: bowlofred
  autocomplete working code sample not working... aviper4u 0 1,602 Oct-24-2020, 03:04 AM
Last Post: aviper4u

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020