The purpose of this code is to print “user flagged” if the username is “jhill”, and otherwise to print “user okay”. Run this code, analyze its output, and debug it. (If you want to undo your changes to the code, you can click the Reset button.)

Automate Cybersecurity Tasks with Python | Weekly challenge 4 Quiz | 

The purpose of this code is to print “user flagged” if the username is “jhill”, and otherwise to print “user okay”. Run this code, analyze its output, and debug it. (If you want to undo your changes to the code, you can click the Reset button.)

def check_user(name): 
if name="jhill":
print("user flagged") 
print("user okay")
check_user("jhill")

How can you fix this error?

  • Call check_user() before the function definition.
  • Remove indentation from the line that prints “user okay” so that it is not part of the conditional.
  • Use the != operator instead of the == operator in the conditional header.
  • Add an else statement before the line that prints “user okay”.

 

Leave a Comment