writing double quotes in python

Solution 1:

With double-quote strings:

file.write("Item \"" + Name[i] + "\" ")

Or with simple quotes:

file.write('Item "' + Name[i] + '" ')

Or with triple double quotes and string interpolation:

file.write("""Item "%s" """ % Name[i])

Or with simple quotes and format:

file.write('Item "{0}"'.format(name[i]))

There are many many ways to declare string literals in Python...

Solution 2:

You can use:

s1 = 'Item "Aaron" RollNo Item "Barry" RollNo'
s2 = "Item \"Aaron\" RollNo Item \"Barry\" RollNo"

In python you can separate string with ' or " chars, and if you use " you can "escape" such char in the middle of the string with \"