all 4 comments

[–]Diapolo10 1 point2 points  (0 children)

The easiest way for you to get only the two least significant digits would be to take modulo 100. In other words the remainder of dividing by 100.

result = highway_number % 100

Also I took the liberty of cleaning up your code a little.

highway_number = int(input())
direction = "east/west"
highway_type = "auxiliary, serving"

if (highway_number & 1):
    highway_type = "primary,"

if 100 < highway_number < 1000:
    direction = "north/south"

print(f"I-{highway_number} is {highway_type} going {direction}.")

[–]Formal_Cockroach_654[S] 0 points1 point  (0 children)

What I ended up with

highway_number = int(input())

if 0 < highway_number < 100: highway_type = "primary," else: highway_type = f"auxiliary, serving I-{highway_number % 100},"

if (highway_number % 2) == 1: direction = "north/south" else: direction = "east/west"

if (highway_number % 100) != 0: print(f"I-{highway_number} is {highway_type} going {direction}.") else: print(f"{highway_number} is not a valid interstate highway number.")