= []
newlist = int(input("Enter a number: "))
number
newlist.append(number)= True
ascending = True
descending while True:
= input("Enter a number: ")
next_number if next_number == '':
break
if int(next_number) < number:
= False
ascending else:
= False
descending int(next_number))
newlist.append(= int(next_number)
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
True
and 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