1 Replies - 247 Views - Last Post: 24 November 2012 - 12:36 AM Rate Topic: -----

#1 BuhRock  Icon User is offline

  • D.I.C Regular

Reputation: 10
  • View blog
  • Posts: 255
  • Joined: 21-February 10

Splitting text into different parts

Posted 24 November 2012 - 12:30 AM

If I were getting raw input with one question like

var = raw_input("Enter the properties of the product in the format Price|Discount|Points")


So If I wanted to get what they input for the price, how would I get just before the first |?
Is This A Good Question/Topic? 0
  • +

Replies To: Splitting text into different parts

#2 jon.kiparsky  Icon User is online

  • Pancakes!
  • member icon


Reputation: 7291
  • View blog
  • Posts: 12,093
  • Joined: 19-March 11

Re: Splitting text into different parts

Posted 24 November 2012 - 12:36 AM

var.split("|")[0]

would do the work.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1