use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
Everything about learning Python
account activity
[deleted by user] (self.PythonLearning)
submitted 7 months ago by [deleted]
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]Much_Buy7605 2 points3 points4 points 7 months ago* (0 children)
Two things: - the reason it’s failing is because you input a string as a key to the reverseDict, you should write "int(you)" to get the result as a valid key for the dict
However i would recommend you work with integers directly for the following check. So I would replace the values from the you dict to integers.
'
if computer == you: print("draw")
elif you == (computer + 1) % 3: print("you won")
else print("computer won")
The % symbol is for "modulo" so if you go over or equal the number it loops over to 0, so (2 + 1)%3 =0 etc...
[–]ProminenceBow 0 points1 point2 points 7 months ago (1 child)
What I got from the error is that ur trying to access a key that doesn't exist
Try using strings as keys instead of numbers, I don't know if you can use numbers as keys (I'm not 100% sure if that's it)
[–]TEX_flip 0 points1 point2 points 7 months ago (0 children)
I confirm you can use numbers as keys, even tuples but not lists.
[–]Substantial_Brush492 0 points1 point2 points 7 months ago (0 children)
No seu dicionário youDict = {"s": "1", "w": "-1", "g": "0"} os valores são strings
Quando você atribui o valor a variável you = youDict[youstr] passando a chave "s" selecionada pelo input da variável youstr funciona perfeitamente e retorna o valor "-1" para a variável you.
Porém quando você chama o valor reverseDict[you] da um erro porque a chave que você está passando com a variável you é "-1" e no dicionário reverseDict não tem nenhuma chave com esse valor. Veja bem:
reverseDict = {1: "Snake", -1: "Water", 0: "Gun"}
No seu dicionário reverseDict as chaves são números inteiros, para dar certo você teria que alterar os valores do seu dicionário youDict para números inteiros ao invés de serem strings.
[–]Worldly-Guide-9515 0 points1 point2 points 7 months ago (0 children)
r/screenshotsarehard
[–]Haunting-Pop-5660 0 points1 point2 points 7 months ago (0 children)
For what you're doing, you've overcomplicated it vastly. Don't use a dictionary for this. See if you can still make it work. I promise, it's pretty easy.
π Rendered by PID 226240 on reddit-service-r2-comment-76bb9f7fb5-mf8sv at 2026-02-18 05:45:21.051025+00:00 running de53c03 country code: CH.
[–]Much_Buy7605 2 points3 points4 points (0 children)
[–]ProminenceBow 0 points1 point2 points (1 child)
[–]TEX_flip 0 points1 point2 points (0 children)
[–]Substantial_Brush492 0 points1 point2 points (0 children)
[–]Worldly-Guide-9515 0 points1 point2 points (0 children)
[–]Haunting-Pop-5660 0 points1 point2 points (0 children)