newlist = []
number = int(input("Enter a number: "))
newlist.append(number)
ascending = True
descending = True
while True:
next_number = input("Enter a number: ")
if next_number == '':
break
if int(next_number) < number:
ascending = False
else:
descending = False
newlist.append(int(next_number))
number = int(next_number)
if ascending:
print("Sequence is in ascending order")
elif descending:
print("Sequence is in descending order")
else:
print("Sequence is not ordered")Pattern: flags
- A flag is a programming pattern: a boolean variable that acts as a signal to the program to determine whether or not the program as a whole or a specific section of the program should run.
- For example, you can set the flag to
Trueand the program will run continuously until any type of event makes itFalse. Then the program, loop, or whatever you’re using a flag for will stop, or do something else.
- For example, you can set the flag to