0
cat_unique = ['greetings',
 'BB_Device_has_physical_damage',
 'Cracked_Shatterd_screen_Yes',
 'Cracked_Shatterd_screen_No',
 'Broken_split_or_deformed_case_Yes',
 'Broken_split_or_deformed_case_No',
 'Is_it_bent_batter_prongs_Yes',
 'Is_it_bent_battery_prongs_No',
 'Laser_window_cracked_Missing_Yes',
 'Laser_window_cracked_Missing_No',
 'Screen_not_respoding_Yes',
 'Screen_not_respoding_No',
 'it_Missed_Trigger_Buttons_Yes',
 'Missed_Trigger_Buttons_No']

I want to print with quotation marks cat_unique[0] as "greetings"? How can i do this?

Netwave
  • 40,134
  • 6
  • 50
  • 93
  • I don't know about PHYTON 3.X, but in python, the quotes are irrelevant here. If you want to _display_ them with quotes, however, you can use `json.dumps(cat_unique)`. – cs95 Sep 08 '17 at 10:58
  • Welcome to SO, could you post your attempts as your question currently sounds like you're asking for code which is not how SO works. – EdChum Sep 08 '17 at 10:59
  • 6
    Possible duplicate of [How to print variable inside quotation marks?](https://stackoverflow.com/questions/27757133/how-to-print-variable-inside-quotation-marks) – erhesto Sep 08 '17 at 11:13

4 Answers4

0

There are a few ways to print ":

print('"'+ cat_unique[0] + '"') # using single quotes
print("\"" + cat_unique[0] + "\"") # escaping the quotes.
Daniel Lee
  • 7,189
  • 2
  • 26
  • 44
0
for elem in cat_unique: print ('{0}{1}{2}'.format('"', elem, '"'))

You can print your list element by using this code.

P.Madhukar
  • 454
  • 3
  • 12
-1

You can just simply add the double quotes to the string

>>> cat_unique = ['"greetings"']
>>> print(cat_unique[0])
"greetings"
Alan Kavanagh
  • 9,425
  • 7
  • 41
  • 65
-1
for i in range(len(cat_unique)):
    cat_unique[i]='"'+cat_unique[i]+'"'

print cat_unique

it will add double quote to each element in list