Python Forum
What is the purpose of this append command!
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
What is the purpose of this append command!
#1
def square(x):
    return x * x


def my_calculation(x, y):
    result = []
    for i in y:
        result.append(x(i))
    return result


squares = my_calculation(square, [1, 2, 3, 4, 5])

print(squares)


sorry everyone, i am a beginner! in these codes i did not understand why we have to do ? Arrow "result.append(x(i))

or if anyone can explain me all steps, would be much appreciated.
thanks again.
Reply


Messages In This Thread
What is the purpose of this append command! - by Captain_farrell - Apr-27-2020, 09:10 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  What is the useful purpose of Python? dorlow 2 2,438 Sep-16-2020, 04:22 PM
Last Post: JaneOgden91fCL
  print scripts example includes comma that seems to serve no purpose flour_power_33 5 4,563 Sep-02-2020, 03:32 AM
Last Post: flour_power_33
  Cant Append a word in a line to a list err "str obj has no attribute append Sutsro 2 4,149 Apr-22-2020, 01:01 PM
Last Post: deanhystad
  Purpose of the keyword "pass" Tim 3 4,055 Feb-24-2018, 07:58 AM
Last Post: buran

Forum Jump:

User Panel Messages

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