Guest User

Untitled

a guest
Oct 20th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. foo = (1, 2, 3)
  2. bar = (4, 5, 6)
  3.  
  4. for (f, b) in some_iterator(foo, bar):
  5. print "f: ", f, "; b: ", b
  6.  
  7. f: 1; b: 4
  8. f: 2; b: 5
  9. f: 3; b: 6
  10.  
  11. for i in xrange(len(foo)):
  12. print "f: ", foo[i], "; b: ", b[i]
  13.  
  14. for f, b in zip(foo, bar):
  15. print(f, b)
  16.  
  17. import itertools
  18. for f,b in itertools.izip(foo,bar):
  19. print(f,b)
  20. for f,b in itertools.izip_longest(foo,bar):
  21. print(f,b)
  22.  
  23. for num, cheese, color in zip([1,2,3], ['manchego', 'stilton', 'brie'],
  24. ['red', 'blue', 'green']):
  25. print('{} {} {}'.format(num, color, cheese))
  26.  
  27. 1 red manchego
  28. 2 blue stilton
  29. 3 green brie
  30.  
  31. for (f,b) in zip(foo, bar):
  32. print "f: ", f ,"; b: ", b
  33.  
  34. def custom_zip(seq1, seq2):
  35. it1 = iter(seq1)
  36. it2 = iter(seq2)
  37. while True:
  38. yield next(it1), next(it2)
  39.  
  40. #value1 is a list
  41. value1 = driver.find_elements_by_class_name("review-text")
  42. #value2 is a list
  43. value2 = driver.find_elements_by_class_name("review-date")
  44.  
  45. for val1 in value1:
  46. print(val1.text)
  47. print "n"
  48. for val2 in value2:
  49. print(val2.text)
  50. print "n"
  51.  
  52. for val1, val2 in zip(value1,value2):
  53. print (val1.text+':'+val2.text)
  54. print "n"
Add Comment
Please, Sign In to add comment