This post has been de-listed
It is no longer included in search results and normal feeds (front page, hot posts, subreddit posts, etc). It remains visible only via the author's post history.
I'm writing a while loop with if statements in it. When I get to the end of one of the if statements I want to break the loop. However when I put in the break command for the first if statement it says there is an indentation error. This is the only line I have this problem with. It is line 17.
from math import sqrt
s = True
while (s is True): print('The sides are a, b, c and c is the hypotenuse') formula = input('Which side (a, b, c) do you wish to calculate? side> ')
if formula == 'c': side_a = int(input('Input the length of side a: ')) side_b = int(input('Input the length of side b: '))
side_c = sqrt(side_a * side_a side_b * side_b)
print('The length of side c is' )
print(side_c)
break
elif formula == 'a': side_b = int(input('Input the length of side b: ')) side_c = int(input('Input the length of side c: '))
side_a = sqrt((side_c * side_c) - (side_b * side_b))
print('The length of side a is' )
print(side_a)
break
elif formula == 'b': side_a = int(input('Input the length of side a: ')) side_c = int(input('Input the length of side c: '))
side_b = sqrt(side_c * side_c - side_a * side_a)
print('The length of side b is')
print(side_b)
break
else: print ("Please Try Again") s is True code
Subreddit
Post Details
- Posted
- 4 years ago
- Reddit URL
- View post on reddit.com
- External URL
- reddit.com/r/learnpython...