grandfathermagic

Third from the right

Apr 30th, 2020
413
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. # 5, 1, 6, 2, 3, 4, 8, 7, 10, 9
  2. i_out = (input("Enter a list with 10 digits ").replace(" ", "")).split(",")
  3. print(type(i_out))
  4. print(len(i_out))
  5. length = len(i_out)
  6. i = 0
  7. new_list = []
  8. if len(i_out) < 10:
  9.     print("That's not a valid length of list - you need 10 digits ")
  10.     i_out = list(input("").split())
  11. else:
  12.     while i < length:
  13.         new_list = i_out
  14.         if new_list[i].isnumeric():
  15.             new_list[i] = int(new_list[i])
  16.             i += 1
  17.         else:
  18.             new_list[i] = str(new_list[i])
  19.             new_list = new_list.sort()
  20.             i += 1
  21. print(new_list)
  22. new_list.sort()
  23. print(new_list)
  24. third_form_the_right = new_list[(length - 3)]
  25. print("third_form_the_right",third_form_the_right)
Advertisement
Add Comment
Please, Sign In to add comment