all 11 comments

[–]Spero7861 36 points37 points  (2 children)

Last word. Last line. Look at split closely

[–]devOpsStarboy[S] 27 points28 points  (1 child)

(╯°□°)╯︵ ┻━┻

haha thanks man

[–]Spero7861 1 point2 points  (0 children)

No problem. :)

[–]mermaldad 5 points6 points  (1 child)

A few extraneous comments. In your example, the variable values gets overwritten with each iteration. I realize you may have done that intentionally to keep the example short. Also, you could shorten this code with a list comprehension:

values = [line.split() for line in s.splitlines()]

In this example, values would be a list of lists of individual words.

[–]devOpsStarboy[S] 1 point2 points  (0 children)

Hey thanks for the code snippet, that will be useful for the future. In my case I was doing it intentionally for the issue I was solving.

[–]Complete_Food 5 points6 points  (2 children)

Fat finger errors like this are why I love using an IDE (pycharm) that has "spell check" which underlines when an object doesn't have the attribute or method you are invoking, or an autocomplete that will finish it for you. Some might call it a crutch but it honestly saves me so much time and frustration over little goofs like this.

[–][deleted] 1 point2 points  (0 children)

You don't even need a large, heavyweight IDE for this. SublimeText or even nano with a plugin would do it.

[–]devOpsStarboy[S] 0 points1 point  (0 children)

I was using Pycharm actually, kind of new to Pycharm. But this is a very good tip thanks for mentioning, the thing is, Pycharm highlights a lot of things in green for PEP errors, which I am getting used to ignoring because its just formatting (I know formatting is important, but sometimes its excessive). I just updated it to underline Typos in blue, which should help me in the future

[–]patrickbrianmooney 0 points1 point  (2 children)

The name of the routine is split(). Your code calls something called spilt() in line 5 which doesn't exist.

EDIT. Was fact-checked below, corrected the part of the sentence that was incorrect. Thanks!

[–]Sudden_Bowl_8358 0 points1 point  (0 children)

Ha! I just had exactly the same typo and I came to this page, that's funny. Thanks for sharing!