【问题标题】:I can't print my code on seperate lines- python 3.4.1我无法在单独的行上打印我的代码-python 3.4.1
【发布时间】:2015-02-17 22:25:52
【问题描述】:
#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)

【问题讨论】:

  • 为什么要使用休息时间?
  • 我还没有做错误处理。我正在用错误消息替换 break 。不过谢谢。 @MalikBrahimi

标签: python list printing newline


【解决方案1】:

要打印列表,您可以使用

for movie in movies:
    print(movie)

【讨论】:

    猜你喜欢
    • 2014-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2013-08-20
    • 2021-04-03
    • 1970-01-01
    • 2022-12-16
    相关资源
    最近更新 更多