So, I recently got into programming in python and decided to make a simple code which ran some simple maths e.g calculating the missing angle in a triangle and other simple things like that. After I made the program and a few others, I thought that maybe other people I know could use this so I decided to try and make this as simple as possible. The code can be found below:
a = int(input("What's one of the angles?"))
b = int(input("What's the other angle in the triangle?"))
c = (a + b)
d = 180
f = int(180 - c)
print(f)
The code itself does work but, the only problem is that if you have more than 1 question, it becomes tedious and a rather cumbersome task to constantly load up Python and hit F5 so, my idea was to have it loop an infinite number of times until you decided to close down the program. Every time I tried searching for a way to do this, all of the while True: statements were for bigger and more complicated pieces of code and with this being maybe my fifth or tenth piece of code, I couldn't understand a few of the coding for it.
I'd appreciate any help or advice for this subject as it'd make my day if anyone's willing to help.
while True:
suggestion is right on the money. For your first looping program you can simply add that to the top of your program, and indent everything below that. – Mike Housky 20 hours agoc = (a + b)
can simply be written asc = a + b
andf = int(180 - c)
can be written asf = 180 - c
– Markus Meskanen 20 hours agod = 180
can be written as nothing since it isn't used at all by the program :) – Two-Bit Alchemist 20 hours ago