Python Forum
Best way to strip() after split()
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Best way to strip() after split()
#11
Python 3.5.2 (default, Jul 17 2016, 00:00:00) 
[GCC 4.8.4] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> data = 'Red Duck | $125 | New | Ready | Very Good'
>>> product, price, condition, available, rating = data.split(' | ')
>>> print(product)
Red Duck
what error do you get - you can see it works in the interpreter. It also works as stand alone script too. Maybe post the code and full traceback.
the box is from using inline tag - in the editor it is second tag from the right - i.e. you have following tags in the editor: python, error, output, inlune, hint
Reply
#12
Never mind! It was a typo in both cases. It is all good now.
Thanks a lot. You have been most helpful
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  extract only text strip byte array Pir8Radio 7 2,909 Nov-29-2022, 10:24 PM
Last Post: Pir8Radio
Smile please help me remove error for string.strip() jamie_01 3 1,181 Oct-14-2022, 07:48 AM
Last Post: Pedroski55
  Can't strip extra characters from Data Canflyguy 7 1,858 Jan-10-2022, 02:16 PM
Last Post: Canflyguy
  strip() pprod 8 3,426 Feb-16-2021, 01:11 PM
Last Post: buran
  Need help with code for my WS2812B (Neopixel) Led Strip Phibbl 1 2,753 Apr-08-2020, 07:18 PM
Last Post: deanhystad
  split strip issues 'NonType' casacafe 8 3,836 Oct-08-2019, 06:29 PM
Last Post: ichabod801
  removing spaces/tabs after used .strip() zarize 0 1,578 Sep-11-2019, 12:46 PM
Last Post: zarize
  strip off just newlines Skaperen 11 5,304 Jun-19-2019, 06:28 PM
Last Post: Skaperen
  strip space from end of a row of text ineuw 4 2,870 Apr-15-2019, 03:14 AM
Last Post: ineuw
  How to remove whitespace from a string when .replace and .strip do not work winnetrie 7 4,440 Jan-05-2019, 08:44 AM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020