-2

how to add each word in this structure to an array?

I want to remove the extra quotations an (\r\n)

for item in most_common_list:
    print(item[0])

enter image description here

dark0307
  • 9
  • 1
  • 4
  • Does this answer your question? [How to remove \n and \r from a string](https://stackoverflow.com/questions/35830924/how-to-remove-n-and-r-from-a-string) – TDG Nov 13 '22 at 17:40

1 Answers1

1

Use the strip() method on your strings to remove whitespace (includes \r and \n)


If it is the case that you have literal \r and \n strings in your text (as opposed to carriage return and newline characters), you should figure out why these are being generated and put into your most_common_lost and fix it at the source. It seems highly likely that they should not be a part of these strings.

Ben Borchard
  • 631
  • 3
  • 9
  • I am not able to remove them using strip() – dark0307 Nov 13 '22 at 18:44
  • Is it possible you have literal `\r` and `\n` strings in your text (as opposed to carriage return and newline characters)? If so, you should figure out why these are being generated and fix it at the source. If not, then strip() will work if you call it correctly. How have you tried to use strip()? How is your `most_common_list` list created? – Ben Borchard Nov 14 '22 at 00:53
  • As you suggested, I fixed it from the source and it works, thanks! – dark0307 Nov 14 '22 at 08:54