title: Appending a list to create a nested list in python
body: <p>I'm trying to make a nested list in Python, by asking the user to input the text file.
  The input file is as shown below:</p>
  
  <p><code>1.3 2.6 3.2 4.1
  1 -3 2
  -4.1
  </code></p>
  
  <p>And finally the output should be:
  [[1.3, 2.6, 3.2, 4.1], [1.0, -3.0, 2.0], [-4.1]]</p>
  
  <p>My code can display the individual list one below the other, but I'm having difficulty in appending the lists.
  As I'm new to python, any help is much appreciated. Thanks in advance.
  My code is as follows:</p>
  
  <pre><code>#Ask the user to input a file name
  file_name=input("Enter the Filename: ")
  
  #Opening the file to read the content
  infile=open(file_name,'r')
  
  #Iterating for line in the file
  for line in infile:
      line_str=line.split()
  
      for element in range(len(line_str)):
          line_str[element]=float(line_str[element])
  
      nlist=[[] for line in range(3)]
      nlist=nlist.append([line_str])
      print(nlist)
  </code></pre>