Parsing/Printing depending on char length in Python; only 98% on CodeEval -


so i'm working through codeeval problem right now, and, reason, can't past 98/100 score.

here's link challenge on codeeval:

https://www.codeeval.com/open_challenges/167/

here's code:

# -*- coding: utf-8 -*- import sys  zeefile = open(sys.argv[1])  line in zeefile:     if len(line) <= 55:        sys.stdout.write(line)     elif len(line) > 55:         line = line[:40].rsplit(" ", 1)[0]         sys.stdout.write(line)         sys.stdout.write('... <read more> \n') 

i've beaten head against wall several hours, few devs far more talented i'll ever be.

we're perplexed, least. ultimately, it's not big deal, i'd know if there's being missed here can learn it.

i've checked code on , over, i've checked input, i've checked output...i can't find inconsistency, or suggests i'm missing last 2% of successful solution.

any idea we're missing why isn't coming 100% legit solution problem? i'm hoping fresh eyes , sharp minds can me out on one! thank much!

try following code (100% on code eval):

import sys  open(sys.argv[1], 'r') in_f:     line in in_f:         line = line.strip()         if len(line) > 55:             line = "{0}... <read more>".format(line[:40].rsplit(" ", 1)[0].rstrip())         sys.stdout.write("{0}\n".format(line)) 

i used file:

tom exhibited. amy lawrence proud , glad, , tried make tom see in face - wouldn't look. tom tugging @ button-hole , looking sheepish. 2 thousand verses great many - very, great many. tom's mouth watered apple, stuck work. 

and got following output:

tom exhibited. amy lawrence proud , glad, and... <read more> tom tugging @ button-hole , looking sheepish. 2 thousand verses great many -... <read more> tom's mouth watered apple, but... <read more> 

code eval score


Comments

Popular posts from this blog

python - No exponential form of the z-axis in matplotlib-3D-plots -

php - Best Light server (Linux + Web server + Database) for Raspberry Pi -

c# - "Newtonsoft.Json.JsonSerializationException unable to find constructor to use for types" error when deserializing class -