Comparison of strings is lexicographically-sensitive

Published: (December 1, 2025 at 07:03 PM EST)
1 min read
Source: Dev.to

Source: Dev.to

Day 78 – December 2nd, 2025

I need to buckle down, as I’m still lagging on day 3 & 4 goals (“Day 3‑4: Control structures (if‑else, loops)”), as well as day 5 (and 6) goals (“Day 5‑6: Functions and modules”), and Day 7 target (exercises). If I haven’t covered this, I can’t make progress on day 8‑77 goals.

Goals

As extracted from the Python for Software Development textbook by Halvorsen (n.d.):

  • Plotting in Python ✅
  • Subplots ✅
  • Exercises ✅
  • If … Else
  • Arrays
  • For Loops
  • Nested For Loops
  • While Loops
  • Exercises
  • Creating Functions in Python – Introduction
  • Functions with multiple return values
  • Exercises
  • Creating Classes in Python
  • The __init__() Function
  • Exercises
  • Creating Python Modules
  • Exercises

Notes

Python for Data Science, AI & Development Course (IBM) (Santarcangelo, n.d.) – Module 2: Python Programming Fundamentals – Conditions and Branching

  • The block of code under an if statement only runs when the condition is True.
  • Comparison of strings is lexicographically‑sensitive (comparison is done character‑by‑character based on Unicode/ASCII ordering) (see also Google, 2025a; Google, 2025b). That’s why "10" comes before "2" when compared as strings.

References

  • Google. (2025b). Google Search with AI. [Large language model].
  • Halvorsen, H. (n.d.). Python.
  • Santarcangelo, J. (n.d.). Python for data science, AI & development [MOOC]. Coursera.
Back to Blog

Related posts

Read more »

Addressing the adding situation

Article URL: https://xania.org/202512/02-adding-integers Comments URL: https://news.ycombinator.com/item?id=46120181 Points: 29 Comments: 0...

What Happens When You Run Python Code?

Python is a popular programming language, but have you ever wondered what happens behind the scenes when you run a Python program on your computer? In this arti...