Python Forum
How to append to list a function output?
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How to append to list a function output?
#1
Hi, I have a following issue. I need to append a function's output into a list. See a simplified code bellow:

def output(n):
    i = n
    for i in range(0, n-1):
        i +=1
        print(i)

output(10)

arr = []
arr.append(output(10))
However, my arr list is still empty. How can I fix it please? Thanks a lot!
Reply


Messages In This Thread
How to append to list a function output? - by rama27 - Aug-23-2020, 07:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  print function output wrong with strings. mposwal 5 502 Feb-12-2021, 09:04 AM
Last Post: DPaul
  How to append multiple <class 'str'> into a single List ahmedwaqas92 2 484 Jan-07-2021, 08:17 AM
Last Post: ahmedwaqas92
  Output with none, print(x) in function Vidar567 3 402 Nov-24-2020, 05:40 PM
Last Post: deanhystad
  output correction using print() function afefDXCTN 2 2,091 Oct-13-2020, 12:58 PM
Last Post: cvilao
  Append list into list within a for loop rama27 2 717 Jul-21-2020, 04:49 AM
Last Post: deanhystad
  Append only adding the same list again and again viraj1123 4 684 Jun-17-2020, 07:26 AM
Last Post: viraj1123
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 679 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  json.dumps list output qurr 12 1,730 Apr-08-2020, 10:13 PM
Last Post: micseydel
  If item in list = true, Output = xx kroh 0 564 Feb-19-2020, 09:17 AM
Last Post: kroh
  Problem with append list in loop michaelko03 0 628 Feb-16-2020, 07:04 PM
Last Post: michaelko03

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020