I'm working on a school assignment and it works (so far) but I don't understand why I had to put the second if statement after else in the tester function for that if p condition (Xavier) to work.
-
I need someone to explain why I couldn't use the
ifbeforeelsein this case. -
The same condition. It actually needs to test if the user input contains an uppercase X. I have searched online but just can't figure out which method to use.
def tester(p, givenstring = "Too short"): result=len(p) if result>=10: print(p) else: print(givenstring) if p == "Is Xavier here?": # if p == "X" doesn't work. print("X is spotted!") def main(): while True: prompt=input("Write something (quit ends): ") if prompt=="quit": break else: tester(prompt) if __name__ == "__main__": main()
Aucun commentaire:
Enregistrer un commentaire