Vijay
Vijay

Reputation: 133

August Month is not print properly in python

List = ['Before : January 28, 1996 6:00:00 PM CST', 'After : December 1, 2028 6:59:59 PM CDT']
enddate_NO_pr = List[1].lstrip('After : ').replace(',','')
print enddate_NO_pr
December 1 2028 6:59:59 PM CDT
>>>
>>>
List = ['Before : January 28, 1996 6:00:00 PM CST', 'After : August 1, 2028 6:59:59 PM CDT']
enddate_NO_pr = List[1].lstrip('After : ').replace(',','')
print enddate_NO_pr
ugust 1 2028 6:59:59 PM CDT

I have start and end date in my list. When i tried to fetch particular items from my list.

"August" Month alone is not display properly. Any suggestion,please.

Upvotes: 1

Views: 26

Answers (1)

Robby Cornelissen
Robby Cornelissen

Reputation: 97152

You shouldn't use lstrip() in this case. It will not remove the prefix, but instead remove all leading characters that appear in the string you pass in.

Since After : contains a capital A, it will be stripped from August as well.

You could do something like this instead:

 enddate_NO_pr = List[1][len('After : '):].replace(',','')

Upvotes: 1

Related Questions