PY
py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
'''
Suggestion how to transform "print" from Python 2 in Python 3 format.
'''
line = 'print "Hello World"'
llst = line.split()
new_line = llst[:]
if llst[0] == 'print':
for i in llst:
if i[0] == '"':
new_line.insert (new_line.index(i), '(')
elif i[-1] == '"':
new_line.insert (new_line.index(i)+1, ')')
print ('Python 2\n{}\n\n'.format(line))
print ('Python 3\n{}'.format(' '.join(new_line)))
Enter to Rename, Shift+Enter to Preview
OUTPUT
Run