Q:

Cannot understand specific Python 3 code

While trying to solve a problem on Hackerank(The Problem).  I checked the solutions of people who have solved this problem.  Here is the solution from one person-
n = input()
l = []
for _ in range(n):
    s = raw_input().split()
    cmd = s[0]
    args = s[1:]
    if cmd ! ="print":
        cmd += "("+ ",".join(args) +")"
        eval("l. "+cmd)
    else:
        print l

I cannot understand line 8 and line 9, can someone explain me these lines?  Can i write line 8 and line 9 in Python 3 as i'm learning Python 3 ?  How ? 

A:

Basically, cmd is constructed by appending the command (say "insert"), to the operands.  This cmd forms a correct python expression (for example l.insert(0,5), to insert 5 at index 0, in list l). 
Here, l. is hardcoded(start of line 9), cmd is initialized in cmd = s[0], and operands are added in line 8.  
eval(str) evaluates the command str, in string format, as if it were in a command line.