Help in displaying odd numbers from 1 to 100 in py - 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 in displaying odd numbers from 1 to 100 in py (/thread-3060.html) |
Help in displaying odd numbers from 1 to 100 in py - RandoomDude - Apr-27-2017 I want a script to display odd numbers from 1 to 100 (in Python 3.x) >Thanks in advance RE: Help in displaying odd numbers from 1 to 100 in py - Mekire - Apr-27-2017 Please show us an attempt so we can try to assist you. RE: Help in displaying odd numbers from 1 to 100 in py - RandoomDude - Apr-27-2017 This is my attempt : for k in range(1,101,2): print(K)But it shows following error
RE: Help in displaying odd numbers from 1 to 100 in py - Larz60+ - Apr-27-2017 place 4 spaces in front of print(k)That makes an indented block RE: Help in displaying odd numbers from 1 to 100 in py - Mekire - Apr-27-2017 As the error says you need to have the second line indented. What tutorial are you following? for k in range(1,101,2): print(k) RE: Help in displaying odd numbers from 1 to 100 in py - ndc85430 - Apr-27-2017 As far as odd numbers go, do you know how to determine whether a number is odd (mathematically, not necessarily in Python)? RE: Help in displaying odd numbers from 1 to 100 in py - wavic - Apr-27-2017 (Apr-27-2017, 04:43 AM)RandoomDude Wrote: This is my attempt :Except for the indentation error, you will get NameError after indentation is ok. In print() you are using upper K RE: Help in displaying odd numbers from 1 to 100 in py - RandoomDude - Apr-27-2017 (Apr-27-2017, 07:30 AM)wavic Wrote: Except for the indentation error, you will get NameError after indentation is ok. In print() you are using upper KWavic,you are the man,i just checked my code and found that i used upper K in between () of the print statement. Thanks |