0

I would need to work with a list of numbers given from the user, but I think if I ask a user to give me a list, he would't be able to put the brackets []. So if I write :

input('Please enter a list of numbers ')

he won't be able to do it so simply. And I also want to ask the user how many times numbers should I put in that list. But how can ask the user to input me say n numbers so that I can use that in a list.

UserMeli
  • 33
  • 1
  • 8

1 Answers1

0

Ask for numbers separated with spaces then use this:

my_list = [int(x) for x in input('Please enter a list of numbers ').split()]
Kenly
  • 24,317
  • 7
  • 44
  • 60