help with simple program - Printable Version +- Python Forum (https://python-forum.io) +-- Forum: Python Coding (https://python-forum.io/forum-7.html) +--- Forum: General Coding Help (https://python-forum.io/forum-8.html) +--- Thread: help with simple program (/thread-6783.html) |
help with simple program - juanb007 - Dec-07-2017 hi can you please help i dont understand why im getting the error: C:\Users\juanb>python Python 3.7.0a2 (v3.7.0a2:f7ac4fe, Oct 17 2017, 16:23:57) [MSC v.1900 32 bit (Intel)] on win32 Type "help", "copyright", "credits" or "license" for more information. >>> bag=[33,44,6,76,7,88,96,79] >>> len(bag) 8 >>> for item in bag: ... print(item) THANKS A LOT !!JUAN RE: help with simple program - buran - Dec-07-2017 at the moment line 7 is at the same level of indentation as line 6. you need to indent the body of the loop >>> bag=[33,44,6,76,7,88,96,79] >>> for item in bag: ... print(item) ... 33 44 6 76 7 88 96 79 >>> RE: help with simple program - j.crater - Dec-07-2017 Hi, Python error messages are usually pretty clear and give good hints, as is the case in your situation. Code inside for block (and other blocks for that matter) needs to be indented one level, meaning you need to add 4 spaces before print. This can be hard to notice if you write directly into an interpreter. I recommend writing code in a text editor and running it as a Python script. |