Try it on paper first. A hint, the key idea and the worked solution are here when you need them.
Say what each line gives, before you run it.
Have you tried it?
Work it out on paper first. It is fine to get stuck or make a mistake: that is how we learn. When you are ready, go through the solution one step at a time, and check each step against your own.
Plan. Each method asks about every character of the text, and the empty text is False.
"2026".isdigit(): all digits. True."-5".isdigit(): the minus sign is not a digit. False."hello world".isalpha(): the space is not a letter. False."hello".isalpha(): all letters. True."abc123".isalnum(): letters and digits only. True."".isdigit(): there is no character, so there is no digit. False."Hello".isupper(): the letters are not all capitals. False.Check. Run the program and compare.
Answer: True, False, False, True, True, False, False.
Log in to join the discussion.
Loading…