Tag: compare
python if string equals

A string is a series of characters, they are mostly used to display text.
To define a string simply type text between quotes. Python accepts single, double and triple quotes.
Related Course:
Python Programming Bootcamp: Go from zero to hero
String input and output
To output text (string) to the screen:
s = "hello world" |
To get text from keyboard:
|
If you use an old Python version (2.x), you need to use:
|
To test your version:
python –version
String Comparison
To test if two strings are equal use the equality operator (==).
#!/usr/bin/python |
To test if two strings are not equal use the inequality operator (!=)
#!/usr/bin/python |
If you are new to Python programming, I highly recommend this book.