Series35. An integer K and K sets of nonzero integers are given. A sign of the completion of each set is the number 0. For each set, output the number of its elements. Output also the total number of elements in all sets.

Solution in Python 3:

import random

K = random.randrange(1,7)

print("K = ",K)

K_Total = 0
for i in range(0,K):
K_Set = 0
x = random.randrange(1,4)
print(x,end="; ")
while x != 0:
K_Set += 1
x = random.randrange(0,4)
print(x,end="; ")
K_Total += K_Set
print()
print("Count of numbers: ",K_Set)
print()
print("Total Count of numbers: ",K_Total)