#๐Ÿ”’ Simple way to subtract with dicts ?

12 messages ยท Page 1 of 1 (latest)

cloud surge
#

I want to subtract one dicts elements from another

signal prismBOT
#

@cloud surge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

cloud surge
#

From this dict

#

this dict

#
with open("t.txt", "r") as file:
    n = int(file.readline())
    figures = ["p", "b", "z", "r", "v", "k"]
    komplektas = {"p": 16, "b": 4, "z": 4, "r": 4, "v": 2, "k": 2}
    tekstas = str(file.readlines())
    figuru_s = {}

    for i in tekstas:
        if i in figures:
            if i in figuru_s:
                figuru_s[i] += 1
            else:
                figuru_s[i] = 1

    left = {}
    for i in figuru_s:
        left = i + str(figuru_s[i] - komplektas[i])
        print(left)
signal prismBOT
#

Hey @cloud surge!

It looks like you pasted Python code without syntax highlighting.

Please use syntax highlighting to improve the legibility of your code and make it easier for us to help you.

To do this, use the following method:
```py
print('Hello, world!')
```

This will result in the following:

print('Hello, world!')```
You can **edit your original message** to correct your code block.
cloud surge
#

That's my code if needed

#

Nvm I figured it out

#

Huzzah

#

!close

signal prismBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.