Skip to content

Tag: python-3.x

Count adjacent repeated elements in the list

What I expect: My code: What I got: I could not count the last element correctly. Here is another input: Answer Your code is not accounting for the last item in the list because you are avoiding an index out-of-bound error in the evaluation of lst[index] == lst[index+1] by iterating over a range of one less t…

How do you split a string into individual characters?

So I am doing this challenge: Question: It’s 1868 and you’ve just bought a telegraph key so you can transmit messages in Morse code directly to your friend using a personal telegraph line. We’ve given you a file morsecode.txt which translates from any character (except a space) to its code. …