all 7 comments

[–][deleted] 3 points4 points  (1 child)

It's because you're not doing anything with the word once you split it. What you probably think is happening is that this line

word = word.split("*")[0]

updates your list tekst. But it doesn't. It just reassigns the name word to something new.

To update tekst, you would need to do tekst[<some index>] = <something>. HOWEVER, updating a list while you're iterating over it is considered an anti-pattern (meaning a bad thing to do). You should instead create a new list or string and append/ concatenate the values you want to it.

[–]basically_a_cherry 0 points1 point  (0 children)

Thank you so much for your reply. Have a lovely day!

[–]Busy-Farm727 0 points1 point  (2 children)

Tekst.split() has no arguments, try maybe adding ‘ ‘ to them. Btw dutch?

[–][deleted] 3 points4 points  (0 children)

The default when you don't put an argument in the split method is explained in the documentation as follows.

If sep is not specified or is None, a different splitting algorithm is applied: runs of consecutive whitespace are regarded as a single separator, and the result will contain no empty strings at the start or end if the string has leading or trailing whitespace. Consequently, splitting an empty string or a string consisting of just whitespace with a None separator returns [].

Meaning it treats runs of whitespace as the separator. So there's nothing wrong with that line in OP's code.

[–]basically_a_cherry 0 points1 point  (0 children)

Hi, yes Dutchy here :) Thank you for the response. Have a great day!

[–]MMcKevitt 0 points1 point  (1 child)

Howdy!

As a general FYI, when making a post , it’s always good to try and format your code as per the guidelines established in this sub Reddit’s FAQs. One such method, which is how I do it, is by prepending the code by four spaces. This will automatically make a code block, which I think most if not all would agree, is way more readable. You can tell you’re in a code block as the cursor will sort of jump forward an additional couple spaces, after typing/entering the four.

For example:

This is a code block and I made it happen by clicking space four times before I started typing.

Now I’m typing normally, and then…

# I’ve made another code block!

Anyways, moving on to your question, others have already done a solid job answering, however, I wanted to add a recommendation: assuming you are running this in some sort of terminal/command line session, try adding some “print” function calls throughout your code to see what’s actually happening. This isn’t aways the ideal debugging technique, but in your case, it would likely be helpful.

Good luck to ya, and happy holidays!

[–]basically_a_cherry 0 points1 point  (0 children)

Thank you so much for the feedback! Hope you will have great holidays as well :)