anonymous
  • anonymous
Please help me with appending list. I want to print only 1 list contained odd numbers but I don't know why it printed 3 lists ( code is below ): x = int(raw_input('Enter an integer:')) y = int(raw_input('Enter an integer:')) z = int(raw_input('Enter an integer:')) s = [x, y, z] odd = [] for e in s: if e%2 != 0: odd.append(e) print'odd=',odd It printed: odd= [3] odd= [3, 5] odd= [3, 5, 7] Thank you for taking your time answering this question
MIT 6.00 Intro Computer Science (OCW)
  • Stacey Warren - Expert brainly.com
Hey! We 've verified this expert answer for you, click below to unlock the details :)
SOLVED
At vero eos et accusamus et iusto odio dignissimos ducimus qui blanditiis praesentium voluptatum deleniti atque corrupti quos dolores et quas molestias excepturi sint occaecati cupiditate non provident, similique sunt in culpa qui officia deserunt mollitia animi, id est laborum et dolorum fuga. Et harum quidem rerum facilis est et expedita distinctio. Nam libero tempore, cum soluta nobis est eligendi optio cumque nihil impedit quo minus id quod maxime placeat facere possimus, omnis voluptas assumenda est, omnis dolor repellendus. Itaque earum rerum hic tenetur a sapiente delectus, ut aut reiciendis voluptatibus maiores alias consequatur aut perferendis doloribus asperiores repellat.
schrodinger
  • schrodinger
I got my questions answered at brainly.com in under 10 minutes. Go to brainly.com now for free help!
e.mccormick
  • e.mccormick
Well, you are printing every time you append. If you only want to print once, you need to remove the indents in front of the print statment. ``` x = 3 y = 5 z = 6 s = [x, y, z] odd = [] for e in s: if e%2 != 0: odd.append(e) print'odd=',odd ```
anonymous
  • anonymous
Thank you so much

Looking for something else?

Not the answer you are looking for? Search for more explanations.