Advertisement
Guest User

Untitled

a guest
May 20th, 2019
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.09 KB | None | 0 0
  1. l = []
  2.  
  3. for i in range(0,5):
  4. valor = input('Digite um valor: ')
  5. if len(l) == 0:
  6. l.append(valor)
  7. elif len(l) == 1:
  8. if l[0] < valor:
  9. l.append(valor)
  10. elif l[0] >= valor:
  11. l.insert(0,valor)
  12. elif len(l) == 2:
  13. for i in range(len(l)):
  14. if valor > l[i-1] and valor < l[i] and i != 0:
  15. l.insert(i,valor)
  16. elif i == 0 and valor < l[0]:
  17. l.insert(0,valor)
  18. elif len(l) == 3:
  19. for i in range(len(l)):
  20. if valor > l[i-1] and valor < l[i] and i != 0:
  21. l.insert(i,valor)
  22. elif i == 0 and valor < l[0]:
  23. l.insert(0,valor)
  24. elif len(l) == 4:
  25. for i in range(len(l)):
  26. if valor > l[i-1] and valor < l[i] and i != 0:
  27. l.insert(i,valor)
  28. elif i == 0 and valor < l[0]:
  29. l.insert(0,valor)
  30. elif len(l) == 5:
  31. for i in range(len(l)):
  32. if valor > l[i-1] and valor < l[i] and i != 0:
  33. l.insert(i,valor)
  34.  
  35.  
  36. print(l)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement