copy "levels" from a file
<p>I need to write a function that read a file and put in list every level of a game in 1 cell.
every cell contains the rows of the level as strings, and every row is an element of the cell.
The final cell should be without the numbers or the words that appears before the level and without "\n" or empty cells.
I implemented this function, but it not working so well for levels looking like this.
some have  any idea?</p>

<p>level from the file</p>

<pre><code>; 1

####
# .#
#  ###
#*@  #
#  $ #
#  ###
####
</code></pre>

<p>as cell in the list:</p>

<pre><code>['####', '# .#', '#  ###', '#*@  #', '#  $ #', '#  ###', '####']
</code></pre>

<p>example of levels I have problem with:</p>

<pre><code>; 154 'Take the long way home.'

 ############################
 #                          #
 # ######################## #
 # #                      # #
 # # #################### # #
 # # #                  # # #
 # # # ################ # # #
 # # # #              # # # #
 # # # # ############ # # # #
 # # # # #            # # # #
 # # # # # ############ # # #
 # # # # #              # # #
 # # # # ################ # #
 # # # #                  # #
##$# # #################### #
#. @ #                      #
#############################
</code></pre>

<p>looking somthing like this:</p>

<pre><code>["54 'Take the long way home.'", '', ' ############################', ' #                          #', ' # ######################## #', ' # #                      # #', ' # # #################### # #', ' # # #                  # # #', ' # # # ################ # # #', ' # # # #              # # # #', ' # # # # ############ # # # #', ' # # # # #            # # # #', ' # # # # # ############ # # #', ' # # # # #              # # #', ' # # # # ################ # #', ' # # # #                  # #', '##$# # #################### #', '#. @ #                      #', '#############################']
</code></pre>

<p>my code:</p>

<pre><code>def loader(filename):

    tmp=[]
    levels=[]
    f=open(filename, "r")
    f=f.read().split(';')
    for line in f:
        tmp.append(line[2:].strip())
    tmp.remove("")
    for i in tmp:
        i=i.split("\n")
        levels.append(i)
    print levels
</code></pre>
