From the course: Python Practice: Operations
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: Are two strings equal? - Python Tutorial
From the course: Python Practice: Operations
Solution: Are two strings equal?
- [Instructor] The solution to this challenge requires us to do two things. First, we need to provide the parameters that our function will accept. We need to know which two strings to compare. So in the function definition, I added first_string, second_string as parameters. So this function will take two arguments when it's called. These arguments will be the strings to compare. Within the function, these values will be represented by first_string and second_string. So we can write return first_string == second_string. Double equals checks whether two values are equal, and the result is a Boolean value, true or false. In our first test case, comparing string one to string two will get back true. And in the second case, comparing string two to string three will get back false. Or at least that's the idea. Let's make sure that this solution works. I'll click Test my code, and I get what I expect. The first comparison is…
Contents
-
-
-
(Locked)
Solution: Are two strings equal?1m 32s
-
(Locked)
Solution: String replacement54s
-
(Locked)
Solution: Reverse a string1m 26s
-
(Locked)
Solution: Format a string1m 26s
-
(Locked)
Solution: Insert into a string1m 41s
-
(Locked)
Solution: Does a string contain all the letters?2m 11s
-
(Locked)
Solution: Anagram validator3m 26s
-
(Locked)
-