-2

How would i eventually remove punctuations in this function? would "(str.maketrans('', '', string.punctuation)" work? And where in the function should I write it?

def convert(lst):
    return  " " .join(lst).split()
lst = ["Good for the price, but poor Bluetooth connections."]
print(convert(lst))    
Sylvester Kruin
  • 3,294
  • 5
  • 16
  • 39
  • https://stackoverflow.com/questions/265960/best-way-to-strip-punctuation-from-a-string/266162#266162 –  Oct 09 '21 at 18:05
  • @BrutusForcus there is an option to flag questions as duplicates – Matiiss Oct 09 '21 at 18:10
  • You can find such functions in this github [repo](https://github.com/KunalTanwar/Tiny-Functions) basically I created them. – Kunal Tanwar Oct 09 '21 at 18:36

1 Answers1

0

In general on Stack Overflow, you would have been better editing your original question with an update on your progress.

string.punctuation is definitely a step in the right direction. You've got a few options including:

As to where? If you do it after you create the list, you'll need to apply it to each element individually. But if you split up the your string transformation function calls (split, join) on the return line into their own lines, you could do it earlier. Try performing one action at a time, then printing the result to see if you can spot where else you can remove punctuation without having to iterate.

Da Chucky
  • 781
  • 3
  • 13
  • this has already been answered on separate question, agreed about the part where one should edit the original question (although seems that it would make it less likely to be seen by anyone but I don't know) but that could have been said in the comments – Matiiss Oct 09 '21 at 18:15