Відповідь:
print("Example of a list: [4, 11, 3, 8, 6]")
list_of_ints = [int(x) for x in input("Enter elements of your list:").split()]
while True:
print("Menu: \nPress 1 to display list in reverse order \nPress 2 to display list in ascending order \nPress any other key to exit")
choice = input("Please enter your choice:")
if choice == '1':
list_of_ints.reverse()
print("List in reverse order:")
print(list_of_ints)
elif choice == '2':
list_of_ints.sort()
print("List in ascending order:")
else:
break
Пояснення:
Перевірка в CMD - успішна
Copyright © 2024 SCHOLAR.TIPS - All rights reserved.
Answers & Comments
Відповідь:
print("Example of a list: [4, 11, 3, 8, 6]")
list_of_ints = [int(x) for x in input("Enter elements of your list:").split()]
while True:
print("Menu: \nPress 1 to display list in reverse order \nPress 2 to display list in ascending order \nPress any other key to exit")
choice = input("Please enter your choice:")
if choice == '1':
list_of_ints.reverse()
print("List in reverse order:")
print(list_of_ints)
elif choice == '2':
list_of_ints.sort()
print("List in ascending order:")
print(list_of_ints)
else:
break
Пояснення:
Перевірка в CMD - успішна