0
Go through the string below and if the length of a word is even print "even!" string = 'I know how to print every word in this
Can anyone explain me this one ?
1 Antwort
+ 2
Hi, jaydeep kadbhane !
(i) Use the built-in function len(s) to get number of characters in the string with the variable name s, and
(ii) use the modulo operator % to get the info about if the number of characters in s are even or not.
n % 2 == 0
becomes True if the number in the variable n is even, otherwise it’s odd. This number n is here the return from the len-function.
(iii) Use a if - else statement sepatate the two different cases.