将字符串插入列表中每个列表的第一个位置

时间:2018-03-17 16:01:40

标签: python python-3.x list

我有这段代码:

import FBSDKCoreKit

import FBSDKLoginKit

  func application(_ application: UIApplication,didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
       FBSDKApplicationDelegate.sharedInstance().application(application, didFinishLaunchingWithOptions: launchOptions)
       return true
  }

  func application(_ app: UIApplication,open url: URL,options: [UIApplicationOpenURLOptionsKey : Any] = [:]) -> Bool
  {

    if #available(iOS 9.0, *) {
        let sourceApplication: String? = options[UIApplicationOpenURLOptionsKey.sourceApplication] as? String
        return FBSDKApplicationDelegate.sharedInstance().application(app, open: url,sourceApplication: sourceApplication, annotation: nil)           

    } 
     return true
  }

  public func application(_ application: UIApplication, open url: URL, sourceApplication: String?, annotation: Any) -> Bool {
       return FBSDKApplicationDelegate.sharedInstance().application(application, open: url as URL!, sourceApplication: sourceApplication, annotation: annotation) 
  }

我的尝试:

frames = input("Enter a number")
lists = [[] for i in range(int(frames))]

但那并没有给我正确的输出

我想在每个列表的第一个索引中插入一个字符串。例如:我想插入for i in lists: lists[0].insert(0,"Page Frame")

"Page Frame"

2 个答案:

答案 0 :(得分:-1)

你可以尝试

for list_ in lists:
    list_.insert(0, "page frame")

答案 1 :(得分:-1)

怎么样:

for lst in lists:
    lst.insert(0, "Page Frame")