How to print a part of a string?

durgadevi1 srirajarajeswaridevikrupa at gmail.com
Sat Apr 16 03:25:39 EDT 2016


On Friday, April 15, 2016 at 8:13:17 PM UTC+8, durgadevi1 wrote:
> Hello all,
> 
> I have another homework problem.
> 
> I have a textfile. It contains lines of string.
> 
> I am required to only print out a certain part of the string.
> 
> For example the textfile contain:
> 
> ABC XXXXX NNNNN
> BCD QQQQQ EEEEE
> ABC WWWWW AAAAA
> 
> 
> I need to print all the parts that come after only ABC.
> 
> That means I need to print only XXXXX from the first line and WWWWW from the second line. 
> 
> I'm not sure of what code to use to achieve that.

Yay! I'm able to complete my homework now. :) Thanks for your replies guys :)



More information about the Python-list mailing list