+ 1

When would you ever have to compare strings?

For example: "abc" < "def"

14th Jan 2017, 8:29 PM
Karl
4 Respuestas
+ 6
oh idk maybe never lol
14th Jan 2017, 8:49 PM
Kawaii
Kawaii - avatar
+ 3
maybe you ask the user for input and if he enter "hey" you Will print hey otherwise bye or idk user = input() if user == "hey": print("Hello!") else: print("I dont understand you")
14th Jan 2017, 8:39 PM
Kawaii
Kawaii - avatar
+ 1
I mean like when would you have to use > or < when comparing strings
14th Jan 2017, 8:44 PM
Karl
0
This is called Lexicographic ordering and based on what I gathered, it's handy when you are trying to make a dictionary aka alphabetical ordering for a set of characters etc.... I've seen a Harvard student use it to write a code for an AI to play Super Mario! and it also has several Wikipedia pages if you're interested to read more about it!
14th Jan 2017, 10:54 PM
Mohammad Hossein Barati
Mohammad Hossein Barati - avatar