You want to use str.strip() to get rid of the newline. If you need to use split, it returns a list. To get the nth item from a list, index the list: ['foo', 'bar'][n].
Incidentally, naming your string str is a bad idea, since it shadows the built-in str function.
Sign up to request clarification or add additional context in comments.
Comments
0
The return value of the split() method is always a list -- in this case, it's given you a single-element list theList = ['ot.jpg']. Like any list, you get what you want out of it by indexing it: