PygLatin Len and > 0 Questions


I finished the PygLatin exercise OK but I want to know what is exactly going on with the code:

What exactly is the len function doing when:

if len(original) > 0

I understand what the is.alpha does. That's simple. But what is 'len' doing and what does it mean when the code is checking > 0? No one is supposed to enter an integer/number anyway, right? So why check if the raw_input is greater than 0?


You are checking if the length of the string is greater than zero, not the value.
The Length of "THIS" is 4
len(original) is checking to see if anything other than a blank was inputted essentially


Oh, that's simple. Thanks.


Can you explain what the len function is doing down below? I understand the slicing, but why len when we already used len earlier.

new_word = word + first + pyg
new_word = new_word[1:len(new_word)]


len is a method that you can use in multiple different ways.

In this code new_word = new_word[1:len(new_word)] you are taking the first indices of new_word and going until an index equal to the length of new_word aka the end of it.
Remember that we start indexing at 0
So your code turns new_word into a copy of new_world sans the first letter


this description helped me understand that in a way that I could comprehend well, thank you :slight_smile:


This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.