- 1 Thank
- 0 Questions
- 418 Views
- by Manoj Gurung almost 2 years ago

NOTE:The following program is written in python.

i = 0

j = 0

k = 0

list_numbers = input("Enter the list of numbers that you want to work with separated by a comma : ").split(',')

for each_elements in list_numbers:

list_numbers[i] = int(each_elements)

i += 1

i = 0

input_number = int(input("What is the the number that you want to get the first and last index of ?"))

for times_1 in list_numbers:

for times_2 in list_numbers:

if list_numbers[i] <= list_numbers[j]:

list_numbers[i], list_numbers[j] = list_numbers[j], list_numbers[i]

j += 1

j = 0

i += 1

for numbers in list_numbers:

if input_number == numbers:

first_index = k

break

k += 1

while True:

if list_numbers[k+1] == input_number:

k += 1

else:

break

print(f"The first index is {first_index} and the last index is {k}")

Please Log In to ask your question.