Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

Exercise: compare strings

  • Create a file called bool_compare_strings.py
  • You can use the len() function to get the length of the string.
  • Ask the user to enter two strings
  • Then ask the user to select if she wants to compare them based on Unicode or based on their length
  • Then tell us which one is bigger.
Input a string: (user types string and ENTER)
Input another string: (user types string and ENTER)
How to compare:
1) Unicode
2) Length
(user types 1 or 2 and ENTER)