From the course: Advanced Python
Unlock this course with a free trial
Join today to access over 25,500 courses taught by industry experts.
Comparing sequences - Python Tutorial
From the course: Advanced Python
Comparing sequences
- [Instructor] There are going to be times when you're going to want to compare two sequences or more sequences to each other. Sequences support value comparison operations, such as equality and greater or less than, but there are some limitations you need to be aware of. So here in my example, I have two list sequences and one tuple sequence. So let's try comparing sequence1 and sequence2 for equality and greater and less than. So I'll just print out the result of each operation. So we'll check to see if sequence1 is equal to sequence2, and we'll also try comparing to see if sequence1 is greater than sequence2. And then we'll do the same thing, but with a less than comparison. So before we run the code, you can see that both sequences start off with the same values. They both have 1 and 2, but then they start to diverge at the third element. This one has 4, then 5, and so on. So let's go ahead and run the code. So the first result is false since the two sequences are obviously…