2015-02-17 67 views
-1
#Creating empty list 
movies = [] 

#Creating variable that will control number of DVD titles we can enter 
dvds = 0 

#Creating the while loop 
while dvds < 1000000: #This ensures that a large amount of DVD titles can be entered depending on user's personal DVD collection 
     print ("Please enter a DVD from your personal collection- press the 'enter key' to stop adding movies") 
     next = input("> ") 

     #If conditional statement to verify input 
     if len(next) > 0 and next.isalpha(): 
       movies.append(next) 
       dvds = dvds + 1 or dvds=='' 

     else: 
       break 

     print (movies) 
+0

为什么要使用一个突破? – 2015-02-17 22:38:51

+0

我还没有完成错误处理。我正在用一条错误消息取代break。但是,谢谢。 @MalikBrahimi – 2015-02-17 22:54:05

回答

3

我的代码打印列表,你可以使用

for movie in movies: 
    print(movie) 
+0

谢谢@Finn :) – 2015-02-17 22:42:53