List through a flat length input



  • n=int(input()) s=ln(list(input()) #длина введенного списка (почему-то стак не пропускает оператор) while s<n:

    I don't understand what I've written, but as far as I'm concerned, tell me how to put a fixed dime on the list, i.e. to determine the condition of the end of the entry and to accept an unlimited number of elements before this condition comes.



  • I guess that's how you do it.

    n = int(input())
    data = list(map(int, input().split()))[:n]
    

    or if the length of the list was less than the given number, it may be:

    n = int(input())
    data = (list(map(int, input().split())) + [0]*n)[:n]
    

Log in to reply
 

Suggested Topics

  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2
  • 2