Jump to content

peawormsworth

Members
  • Posts

    1
  • Joined

  • Last visited

Posts posted by peawormsworth

  1. I believe this page: https://www.w3schools.com/python/ref_keyword_assert.asp has incorrect wording on the 2nd example. The assertion checks for the presence of 'goodbye' in x, but the message says that "x should be 'hello'". When the assertion is false the error message will appear. However, the message says it should be 'hello' when IT IS 'hello'. That is not logical according to the english words used in the error message. I think the code should be:

     

    x = "goodbye"
    
    #if condition returns False, AssertionError is raised:
    assert x == "hello", "x should be 'hello'"

    It will report "x should be 'hello'" when x is NOT hello.

    It says the opposite of what it means when you run it here: https://www.w3schools.com/python/trypython.asp?filename=demo_ref_keyword_assert2

×
×
  • Create New...