text: 10 Neat Python Tricks Beginners Should Know
  Trick #1Trick #1
  Reversing a string in PythonReversing a string in Python
  "codementor" print "Reverse is",a[::-1] Reverse is rotnemedoca =
  Trick #2Trick #2
  Transposing a MatrixTransposing a Matrix
  1, 2, 3], [4, 5, 6]] zip(*mat) [(1, 4), (2, 5), (3, 6)]mat = [[
  Trick #3Trick #3
  a = [1,2,3]a = [1,2,3]
  Store all three values of the list in 3 new variablesStore all three values of the list in 3 new variables
  1, 2, 3] x, y, z = a x 1 y 2 z 3a = [
  Trick #4Trick #4
  a = ["Code", "mentor", "Python", "Developer"]a = ["Code", "mentor", "Python", "Developer"]
  Create a single string from all the elements in list above.Create a single string from all the elements in list above.
  print " ".join(a) Code mentor Python Developer
  Trick #5Trick #5
  List 1 = ['a', 'b', 'c', 'd']List 1 = ['a', 'b', 'c', 'd']
  List 2 = ['p', 'q', 'r', 's']List 2 = ['p', 'q', 'r', 's']
  Write a Python code to printWrite a Python code to print
  - ap
  - bq
  - cr
  - ds
  for x, y in zip(list1,list2): print x, y ... a p b q c r d s
  Trick #6Trick #6
  Swap two numbers with one line of code.Swap two numbers with one line of code.
  7 b=5 b, a =a, b a 5 b 7a=
  Trick #7Trick #7
  Print "codecodecodecode mentormentormentormentormentor" without using loopsPrint "codecodecodecode mentormentormentormentormentor" without using loops
  print "code"*4+' '+"mentor"*5 codecodecodecode mentormentormentormentormentor
  Trick #8Trick #8
  a = [[1, 2], [3, 4], [5, 6]]a = [[1, 2], [3, 4], [5, 6]]
  Convert it to a single list without using any loops.Convert it to a single list without using any loops.
  Output:- [1, 2, 3, 4, 5, 6]Output:- [1, 2, 3, 4, 5, 6]
  import itertools list(itertools.chain.from_iterable(a)) [1, 2, 3, 4, 5, 6]
  Trick #9Trick #9
  Checking if two words are anagramsChecking if two words are anagrams
  def is_anagram(word1, word2): """Checks whether the words are anagrams. word1: string word2: string returns: boolean """
  Complete the above method to find if two words are anagrams.
  from collections import Counter def is_anagram(str1, str2): return Counter(str1) == Counter(str2) is_anagram('abcd','dbca') True is_anagram('abcd','dbaa') False
  Trick #10.Trick #10.
  Taking a string input.Taking a string input.
  For example "1 2 3 4" and return [1, 2, 3, 4]
  Remember list being returned has integers in it.
  Don't use more than one line of code.
  lambda x:int(x) ,raw_input().split()) 1 2 3 4 result [1, 2, 3, 4]result = map(
  nice tricks this really improved my python skills .
  super trics.
  please mention if any other trics also there.
  it’d be better to explain HOW these work instead of just posting the tricks…
  Can anyone explain me trick #6 swap numbers?
  a, b = b, a
  Everything on the right hand side of the equal sign is evaluated before being passed to the left hand side for assignment.
  So the expression is equal to
  a, b = 5, 7
  For trick #10
  In latest python version,i.e py3, it’s elegant to use list comprehension as
  res = [int(x) for x in input().split()]
  Here one can see 2 differences,
  Another nice trick: you can use zip for more than 2 lists. For example:
  >>> zip([‘a’, ‘b’, ‘c’], [2, 4, 12], [True, False, True])
  [(‘a’, 2, True), (‘b’, 4, False), (‘c’, 12, True)]
  For trick #10 I would just use:
  >>> [int(n) for n in “1 2 3 4”.split()]
  [1, 2, 3, 4]
  This works:
  result = map(int, raw_input().split())
  @JustSomeDude yes it does.
  Just try it out.
  True that.
  Not only does it work, it’s also more readable. At least as far as call semantics go, “lambda x:y(x)” is always the same as simply writing “y”.
  For trick #10 I would use:
  >>> [int(n) for n in “1 2 3 4”.split()]
  [1, 2, 3, 4]