Assertion Error

Joined
Jan 11, 2023
Messages
2
Reaction score
0
I have created a temperature conversion program. It works fine for the most part. However, I'm receiving an "Assertion Error" message:

Python:
def convert_to_fahrenheit(degrees_celsius):
    f = degrees_celsius * (9 / 5) + 32
    print(f)


def convert_to_celsius(degrees_fahrenheit):
    c = (degrees_fahrenheit - 32) * (5 / 9)
    print(c)


while True:
    try:
        assert convert_to_celsius(11)
    except AssertionError as error:
        print("Assertion Error")
        break


I've tried to figure out what could be causing the error message but having difficulty getting to the root of the issue.

I'm currently learning Python and could use some pointers on this. Thanks.
 
Joined
Dec 10, 2022
Messages
73
Reaction score
22
Think that you misunderstand what assert is used for. It's mainly used for debugging. If true is returned then nothing happens if false is returned then an assertion error is thrown.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top