printing - python 3 print generator -


There is a problem when I work with the print () function (Python 3).

When I see the sum of the series, I can use the following code patterns:

  gt; & Gt; The amount (for the range (in 101))  

But when I check the series I made: (I select print () and I agree that Line will print by line)

  & gt; & Gt; & Gt; Print (for range (in 101)  

It has become a generator object, without any cost return. So I have to use the list () to check the series. Is there a flaw in the print function?

PS: An example is for creating a generator written above, not the simplest form for the natural series, but the bone structure for the complex series. For convenience of chain pricing check, I am looking for a way to print each value line from the line.

sum takes you to a run of things to add, Whereas print takes different arguments to print if you want to feed all generator items separately from print , then * notation :

  In the category for print (* (i (1, 101)))  

You really do not need a generator in any case However,:

  sum (category (1, 101)) print (* range (1, 101))  

If you want them in separate lines, then you are expecting behavior of multiple individual calls at print , which means that you are expecting the loop behavior regularly :

  generator_or_range_or_whatever for items: print (items)  

However, you also have the option as an item divider '\ n' Specify:

  print (* generator_or_range_ or_ whatever, sep = '\ n')  

Comments

Popular posts from this blog

sqlite3 - UPDATE a table from the SELECT of another one -

c# - Showing a SelectedItem's Property -

javascript - Render HTML after each iteration in loop -