[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Advice apreciated :) [code] # My goal is to change the contents

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 5
Thread images: 1

File: waifu.jpg (27KB, 250x367px) Image search: [Google]
waifu.jpg
27KB, 250x367px
Advice apreciated :)
[code]
# My goal is to change the contents of a chosen variable
a1 = 33
a2 = 22

input = "a1" # raw_input(">-")
#Command Dict.
comdic = {"a1":a1,"a2":a2,}

# Geting information works just fine
print comdic[input], a1

# changing the choosen variable does not
comdic[input] = 1337

# as seen here, "a1" stays the same
# but a new unknown variable inherits 1337
print comdic[input], a1
[/code]
>>
>>334430
You have 2 different things:
- a1 the variable, and
- 'a1', the key of comdic corresponding to the value 33
Changing 'a1' in the dictionary doesn't touch the actual a1 variable.
>>
>>334437
that explains the unknown variable, thx anon.

Now i just need to figure out how to change the original variable.
>>
>>334441
Uh, that should be trivial. Or am I misunderstanding what you're asking?
>>
>>334430
OP, click this and come back once you've completed it: https://www.codecademy.com/courses/introduction-to-python-6WeG3/0/1
Thread posts: 5
Thread images: 1


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.