Advertisement
sissou123

Untitled

Mar 27th, 2022
602
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.95 KB | None | 0 0
  1. Python Compare Strings – How to Check for String Equality
  2. In this article, we'll see various operators that can help us check if strings are equal or not. If two strings are equal, the value returned would be True. Otherwise, it'll return False.
  3.  
  4. How to Check for String Equality in Python
  5. In this section, we'll see examples of how we can compare strings using a few operators.
  6.  
  7. But before that, you need to have the following in mind:
  8.  
  9. Comparisons are case-sensitive. G is not the same as g.
  10. Each character in a string has an ASCII value (American Standard Code for Information Interchange) which is what operators look out for, and not the actual character. For example, G has an ASCII value of 71 while g has a value of 103. When compared, g becomes greater than G.
  11. How to Compare Strings Using the == Operator
  12. The == operator checks if two strings are equal. Here is an example:
  13.  
  14. print("Hello" == "Hello")
  15. # True
  16. for more: https://www.clictune.com/eAiV
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement