Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #77873
| From | Christian Gollwitzer <auriocus@gmx.de> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Lists |
| Date | 2014-09-15 08:04 +0200 |
| Organization | A noiseless patient Spider |
| Message-ID | <lv5vgi$ehv$1@dont-email.me> (permalink) |
| References | <12kc1a5j82lak7tmnatvhk84fh2ne08s24@4ax.com> |
Am 15.09.14 04:40, schrieb Seymore4Head: > nums=range(1,11) > print (nums) > I don't understand why the command nums=range(1,11) doesn't work. > I would think that print(nums) should be 1,2,3 ect. > Instead it prints range(1,11) It does work, but in a different way than you might think. range() does not return a list of numbers, but rather a generator - that is an object which produces the values one after another. But you can transform it into a list: print(list(nums)) should give you what you want. Christian
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Lists Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-14 22:40 -0400
Re: Lists Christian Gollwitzer <auriocus@gmx.de> - 2014-09-15 08:04 +0200
Re: Lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-15 17:09 +1000
Re: Lists Peter Otten <__peter__@web.de> - 2014-09-15 09:36 +0200
Re: Lists Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-15 09:53 -0600
Re: Lists Peter Otten <__peter__@web.de> - 2014-09-15 18:16 +0200
Re: Lists Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2014-09-15 16:59 +1000
Re: Lists Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-15 11:27 -0400
Re:Lists Dave Angel <davea@davea.name> - 2014-09-15 09:05 -0400
Re: Lists Seymore4Head <Seymore4Head@Hotmail.invalid> - 2014-09-15 11:28 -0400
csiph-web