Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7711531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T01:23:58+00:00 2026-06-01T01:23:58+00:00

I have a string. s = ‘1989, 1990’ I want to convert that to

  • 0

I have a string.

s = '1989, 1990'

I want to convert that to list using python & i want output as,

s = ['1989', '1990']

Is there any fastest one liner way for the same?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T01:23:59+00:00Added an answer on June 1, 2026 at 1:23 am

    Use the split method:

    >>> '1989, 1990'.split(', ')
    ['1989', '1990']
    

    But you might want to:

    1. remove spaces using replace

    2. split by ‘,’

    As such:

    >>> '1989, 1990,1991'.replace(' ', '').split(',')
    ['1989', '1990', '1991']
    

    This will work better if your string comes from user input, as the user may forget to hit space after a comma.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have string like \LESSING\root\cimv2:Win32_UserAccount.Domain=LESSING,Name=Admin How to convert it to LESSING\Admin using Framework?
i have string stored in python variables, and i am outputting a html that
I have String like Dec 31, 1969 4:00:00 PM. I want to convert it
I have string variable that contain price. For example, 10000 . I want use
Have String str May 23 2011 12:20:00, want to convert it to date such
I have string like file name . I want to output like file\ name
I have string that I want to chop to array of substrings of given
I have String variable called jsonString : {"phonetype":"N95","cat":"WP"} Now I want to convert it
I have string on the format $0Option one$1$Option two$2$Option three (etc) that I want
I have string like 123-123-1234 so I want to convert string into this format

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.