5 ms·
I prefer: cuilBuzz = { '1': 'All the rage!', '2': 'Worst product e-v-e-r", '3': None } day = 3 cuilBuzz[day]
by thomasmallen 18y ago
I prefer:
cuilBuzz = {
'1': 'All the rage!',
'2': 'Worst product e-v-e-r",
'3': None
}
day = 3
cuilBuzz[day]
- KirinDave 18y agoIt is weird and magical to me that the lisp guy got modded up but the JavaScript guy got modded down.
- toxik 18y agoYou'd think it's JavaScript, but actually, it's Python.
- deleted 18y ago[deleted]
- chengmi 18y agoMaybe he got modded down for posting code that won't run.
- thomasmallen 18y agoI wrote it in Python, actually. And it has some very obvious bugs. Here's the revised code: cuilBuzz = { '1': 'All the rage!', '2': 'Worst product e-v-e-r', '3': None } day = '3' print cuilBuzz[day] # Although the print isn't necessary... Now what would be interesting would be an accurate version using the datetime module...
- dmpayton 18y agoThis is my preferred method for Python (faux-)switches: cuil_buzz = { 1: 'All the rage!', 2: 'Worst product e-v-e-r.', 3: ' ... ' }.get(day, None)