Guest User

Untitled

a guest
Jan 4th, 2018
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.57 KB | None | 0 0
  1. ############################################
  2. #Wprawka 4 ( środa 6.12, PR)
  3. #Napisz funkcję reprezentant(L), która dla niepustej listy liczb całkowitych dodatnich L
  4. # znajduje najmniejszą liczbę k-cyfrową, gdzie k jest liczbą cyfr największej liczby.
  5. ############################################
  6.  
  7.  
  8.  
  9. def reprezentant(L):
  10. maks=0
  11. mala=0
  12. for i in L:
  13. if len(str(i))>maks:
  14. maks=len(str(i))
  15. mala=i
  16. for i in L:
  17. if len(str(i))==maks and i<mala:
  18. mala=i
  19. return mala
  20. print(reprezentant([1,2,12,22]))
Advertisement
Add Comment
Please, Sign In to add comment