Computer Science, asked by aktech20045, 5 months ago

A traveler wants to start his/her journey from Pune to Ahmedabad. Before starting the journey, he/she uses the GPS system to find all the paths to reach from the source to the destination. He/she will use the smallest or the second smallest path to start the journey. Write a logic to find the smallest and the second smallest distance from the list of all distances.

Input

1. The first input contains N, the total number of paths from the source to the destination

2. The second input contains N sorted integers separated by newline A1, A2 An,

representing the distance of all paths. Output Output contains two numbers separated by

a single space character.​

Answers

Answered by ajinkyamore3515
2

Answer:

def smallestPath(n):

if(n<2):

print("Invalid Syntex")

else:

for i in range(0,n):

ele=int(input())

lst.append(ele)

lst.sort()

print(lst[0])

print(lst[1])

n=int(input("Number of Input"))

lst= []

smallestPath(n)

Explanation:

Define a function - add logic - define driver main - input values.

Similar questions