Hello guest, if you read this it means you are not registered. Click here to register in a few simple steps, you will enjoy all features of our Forum.
Bottom Page

Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Why isn't this code working ? (noob here)
It should output the list with the dictionary with the changed values as specified in the second for loop, but it doesnt. Picture of output is included.

 aliens = []
for l in range (1,30):
    alien_specs = {'speed':'high' , 'color':'blue' , 'points': 5 }

for pi in aliens[:2]:
    if alien_specs['points'] == 5:
        alien_specs['speed'] = 'low'
        alien_specs['color'] = 'red'

for j in aliens[:5]:

Im using python 3
for pi in aliens[:2]:
    if pi['points'] == 5:
        pi['speed'] = 'low'
        pi['color'] = 'red'
99 percent of computer problems exists between chair and keyboard.

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  VS Code Intellisense not working JGFMK 4 114 May-13-2018, 10:45 AM
Last Post: JGFMK
  coding error from a script (absolute noob) fuchls 1 74 May-11-2018, 11:45 PM
Last Post: micseydel
  SQL code not working eml 1 95 Apr-16-2018, 05:18 PM
Last Post: nilamo
  Noob needing some help TheDovah7 2 114 Mar-06-2018, 04:21 PM
Last Post: buran
  pyython code copied 1to1 from book not working. BlackReptile 2 118 Feb-21-2018, 02:46 AM
Last Post: abhin
  Simple Element Check Code in Selenium Not Working digitalmatic7 1 121 Feb-18-2018, 06:53 AM
Last Post: metulburr
  Python code not working noelaronc 2 131 Feb-17-2018, 07:52 PM
Last Post: noelaronc
  Another working code, help required for faster multithreading execution anna 0 142 Feb-09-2018, 03:26 AM
Last Post: anna
  Help required for faster execution of working code anna 2 174 Feb-09-2018, 03:00 AM
Last Post: anna
  Unable to read csv file inside full code snippet, at the same time its working seprat sreeraj 2 157 Jan-28-2018, 07:25 PM
Last Post: sreeraj

Forum Jump:

Users browsing this thread: 1 Guest(s)