Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random
- zoznam = []
- for i in range(10):
- cislo = random.randint(1, 100)
- zoznam.append(cislo)
- sucty = []
- for cislo in zoznam:
- sucet = 0
- # str(cislo) ako v jednoduchej ulohe vyuzijeme pre jednoduche rozdelenie na cifry
- for cifra in str(cislo):
- # kazdu cifru prekonvertujeme spat na cislo aby sme ich mohli scitat
- sucet += int(cifra)
- sucty.append(sucet)
- print("Zoznam:", zoznam)
- print("Ciferne sučty:", sucty)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement