zip is a built-in function that takes two or more sequence and ‘zips’ them into a list of tuples, where each tuple contains one element from each sequence.

The result is a list of tuples where each tuple contains a character from the string and the corresponding element from the list. If the sequences are not the same length, the result gets the length of the shorter one. You can use tuple assignment to traverse a list of tuples:

If you combine zip, for and tuple assignment, you get a standard idiom for traversing two (or more) sequences at the same time. For example, has_match takes two sequences, t1 and t2, and returns True if there is an index i such that t1[i] == t2[i]:

If you need to traverse the elements of a sequence and their indices, you can use the built-in function enumerate:

from Thinking in Python

最新文章

  1. sql之连表查询--效率 通过分析各种连接查询的实现原理来了解
  2. Leetcode Find K Pairs with smallest sums
  3. centos7 docker mysql56
  4. Xcode的Architectures和Valid Architectures的区别,
  5. linux man使用方法 和centos安装中文man包 --转
  6. hdoj 2112 HDU Today
  7. Dos命令---ipconfig
  8. angularJs中自定义directive的数据交互
  9. QGIS
  10. WPF类层次结构
  11. Java IO学习--(一)概述
  12. intelij IDEA破解
  13. python-MYSQL(包括ORM)交互
  14. PyQt5之使用Qt下的designer工具将.ui文件转换成.py文件后添加什么东西后方可运行
  15. 关于php条形码生成(barcode),修改样式
  16. vue 周期函数
  17. 对k8s service的一些理解
  18. RxJava+Retrofit+OkHttp,一步一步封装网络框架;
  19. 最顶尖的12个IT技能
  20. SEO工作中如何增加用户体验?10个细节要注意!

热门文章

  1. Double 与 Float 的值的比較结果
  2. org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files (x86)\Java\jdk1.7.0_7
  3. tensorflow入门教程和底层机制简单解说——本质就是图计算,自动寻找依赖,想想spark机制就明白了
  4. angular4(2-1)angular脚手架引入第三方类库(jquery)
  5. java高级——暴力反射
  6. Windows常见软件故障及解决方案
  7. MySQL学习(一)——启动和登录MySql遇到的问题及解决
  8. 解决IE7、IE8样式不兼容问题
  9. plsql 查询历史执行语句
  10. wepy框架的API的预加载$preload这功能阔以喔