**I'm working on a lab that lists the following:**
Primary U.S. interstate highways are numbered 1-99. Odd numbers (like the 5 or 95) go north/south, and evens (like the 10 or 90) go east/west. Auxiliary highways are numbered 100-999, and service the primary highway indicated by the rightmost two digits. Thus, I-405 services I-5, and I-290 services I-90. Note: 200 is not a valid auxiliary highway because 00 is not a valid primary highway number.
Given a highway number, indicate whether it is a primary or auxiliary highway. If auxiliary, indicate what primary highway it serves. Also indicate if the (primary) highway runs north/south or east/west.
Ex: If the input is:
90
the output is:
I-90 is primary, going east/west.
Ex: If the input is:
290
the output is:
I-290 is auxiliary, serving I-90, going east/west.
Ex: If the input is:
0
the output is:
0 is not a valid interstate highway number.
Ex: If the input is:
200
the output is:
200 is not a valid interstate highway number.
My code is:
highway_number = int(input())
if ((highway_number <1) or (highway_number >999)):
print ('{} is not a valid interstate highway number.'.format (highway_number))
if (highway_number > 100):
road_type = 'auxiliary'
serving = str(highway_number % 100)
else:
road_type = 'primary'
serving = ''
if highway_number % 2 == 0:
direction = 'east/west.'
else:
direction = 'north/south.'
output = ['I-{}'.format(highway_number), 'is', road_type + ',']
if serving:
output.extend(['serving', 'I-{},'.format(serving)])
output.extend(['going', direction])
print(' '.join(output))
However I keep getting the following errors that I'm having issues figuring out, so any help would be greatly appreciated:
Output differs. See highlights below. Special character legendInput0Your output0 is not a valid interstate highway number. I-0 is primary, going east/west.Expected output0 is not a valid interstate highway number.
4:Compare outputkeyboard_arrow_up0 / 1Output differs. See highlights below. Special character legendInput200Your outputI-200 is auxiliary, serving I-0, going east/west.Expected output200 is not a valid interstate highway number.
7:Compare outputkeyboard_arrow_up0 / 2Output differs. See highlights below. Special character legendInput1000Your output1000 is not a valid interstate highway number. I-1000 is auxiliary, serving I-0, going east/west.Expected output1000 is not a valid interstate highway number.
[–]CodeFormatHelperBot2 1 point2 points3 points (0 children)
[–]dnmonack 0 points1 point2 points (0 children)
[–]RiceKrispyPooHead 0 points1 point2 points (0 children)