Python program to arrange elements in alphabetical order

In this post, we will learn about how to arrange an elements in alphabetical order. Method-1: print("Enter three city names")
a,b,c=input(),input(),input()
if a<b<c:
print(a,b,c)
elif a<c<b:
print(a,c,b)
elif b<a<c:
print(b,a,c)
elif b<c<a:
print(b,c,a)
elif c<a<b:
print(c,a,b)
else:
print(c,b,a) Method-2: print("Enter three city names")
a,b,c=input(),input(),input()
x=min(a,b,c)
print(x)
if x==a:
print(min(b,c),max(b,c))
elif x==b:
print(min(a,c),max(a,c))
else:
print(min(a,b),max(a,c)) Happy coding! Follow us on Instagram @programmersdoor Join us on Telegram @programmersdoor Please write comment if you find any bug in above code/algorithm, or find other ways to solve the same the same problem. Follow programmers Door for more. #blog #interview #placement #learn #computer #science

        Contact Us

programmersdoor@gmail.com

  • LinkedIn
  • Facebook
  • Instagram

©2023 by Programmers Door