Hello!
My this time question is about breaking a list.
I have a list with the name favorite_movies. Here is 2 functions of all functions from the file:

def add():
    load_favorite()
    favorite_movies.append(ent.get())
    dump_favorite()
    #print (colors)




def view():
    load_favorite()
    from Tkinter import *

    v = Tk()

    v.geometry('300x300')
    v.configure(background = 'white')

    top = Label(v)
    top.pack()

    top.configure(text = favorite_movies)

    v.mainloop()
    dump_favorite()

When i append a name with the Add button and then press the View button, i see list's names on the Tkinter window like this: spiderman lastnight matrix

but i want them to be displayed like this:
spiderman
lastnight
matrix

What should i do?

Recommended Answers

All 4 Replies

You split them and add a newline so they are on new lines. We don't know what type of variable favorite_movies is so there is no way to give an exact answer, but it is something along the same lines as

favorite_movies="spiderman lastnight matrix"
print favorite_movies
print "\n".join(favorite_movies.split())

Let's hope your movie title does not have two words.

Good point. Am assuming from "lastnight" that titles don't contain spaces. And if they do, the concept is still the same.

Thank you @woooee. It helped.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.