Jump to content
peawormsworth

Peabody Wormsworth

Recommended Posts

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

Share this post


Link to post
Share on other sites

You should use the "Report error" link at the bottom of the page in question so that the staff can be made aware of the issue. They almost never visit the forums.

Share this post


Link to post
Share on other sites

How I read it is

x = "hello" #set variable value

#if condition returns False, AssertionError is raised:
assert x == "goodbye", # compare with condition that set value is equal to "goodbye" which is false

"x should be 'hello'" #on false shows message what the variable value is set to, and that it should be "hello"
Edited by dsonesuk

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...