get input

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sabari cg
    New Member
    • Feb 2012
    • 1

    get input

    how to get multiple values in array on python
    example
    for(i=1;i<=3;i+ +)
    scanf("%d",&a[i]);

    how to do this action in python
  • Smygis
    New Member
    • Jun 2007
    • 126

    #2
    Not sure what exactly that action does since I do not program in C so here are what I guess it does:
    Code:
    a = []
    for i in range(1,4):
    	a.append(i)
    
    	
    print a
    >>> [1, 2, 3]

    Comment

    • bvdet
      Recognized Expert Specialist
      • Oct 2006
      • 2851

      #3
      As a list comprehension:
      Code:
      >>> a = [i for i in range(1,4)]
      >>> a
      [1, 2, 3]
      >>>

      Comment

      Working...