So far, we have just been looking at data types, which should show you how powerful Python’s data types are. However, you cannot write complex programs without conditional statements and loops.
Python has most of the standard conditional checks, such as
> (greater than),
<= (less than or equal to), and
== (equal), but it also adds some new ones, such as
in. For example, we can use
in to check whether a string or a list contains a given character/element:
>>> mystring = "J Random Hacker">>> "r" in mystringTrue>>> "Hacker" in mystringTrue>>> "hacker" in mystringFalse
The last example demonstrates how it is case sensitive. We can use the operator for lists, too:
>>> mylist = ["soldier", "sailor", "tinker", "spy"]>>> "tailor" ...