-1

I am facing problem to take number of inputs from user then storing it in an array,how to print this array

n = int(input())
arr = map(int, input().split())

Thanks in advance for the help

Patrick Haugh
  • 59,226
  • 13
  • 88
  • 96
Pragati
  • 7
  • 4

1 Answers1

0

In Python, map takes a function as one argument and a list as the second argument and applies that function to all of the items in the list. The catch is that this application is lazy, meaning that it returns a map object (which is a generator), and doesn't actually apply the function until you try to iterate through arr.

In your case, if you want to print out the contents of arr, you can simply do:

arr = list(map(int, input().split()))

Calvin Godfrey
  • 2,171
  • 1
  • 11
  • 27