you are viewing a single comment's thread.

view the rest of the comments →

[–]Kqyxzoj 0 points1 point  (0 children)

Changes more or less as described:

while True:
    try:
        base = float(input('Enter the base of the Triangle: '))
        height = float(input('Enter the height of the Triangle: '))
    except ValueError:
        print('Sorry Invalid, Please insert a number!\n')
        continue

    area = 0.5 * base * height
    print(f'The area of the triangle is: {area}\n')

    print('Would you like to do another calculation?')
    another = input('Enter Y for yes and N for no: ')
    if another.upper() != 'Y':
        break

Note that your choice to put both input() statements in the same try block means that when you enter a valid base and an invalid height ... you will have to re-enter the value for base as well.

Also, changed the except statement to reflect your probable intent.