Untitled

mail@pastecode.io avatar
unknown
plain_text
a year ago
1.4 kB
3
Indexable
Never
# zadanie 1
def zamiana(słowo):
    
    słowo = słowo.lower()
    second_word = ""
    for letter in słowo:
        if letter == " ":
            continue
        else:
            second_word += letter
    print(second_word)
    litery = {}
    new_word = ""

    for letter in słowo:
        if letter not in litery:
            litery[letter] = 1
        else:
            litery[letter] += 1
    for i in słowo:
        if litery[i] == 1:
            new_word += "("
        elif i == " ":
            new_word += " "
        else:
            new_word += ")"
    return new_word
print(zamiana("Ala ma kota"))


# zadanie 2
def give_cards(list, no_of_players):

    dictionary = {}

    for i in range(0,no_of_players):
        dictionary[i]=[]

    player = 0
    
    for i in range(len(list)):
        if player >= no_of_players:
            player = 0
        if i % no_of_players == player:
            dictionary[player].append(list[i])
            player += 1
    print(dictionary)

    sum = 0
    for i in range(len(dictionary[0])):
       # if i >= 2 and i <= 10:
        #   sum += 
        if i == "W":
            sum += 2
        if i == "D":
            sum += 3
        if i == "K":
            sum += 4
        if i == "A":
            sum += 5

    print(sum)
        
give_cards([2,4,7,3,'K','A',2], 2)