Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Python Problem of function. and Can you please give me explaination in detail I

ID: 3599536 • Letter: P

Question

Python Problem of function. and Can you please give me explaination in detail I am still new with coding and I want to understand more not just look at the solution. Also How to solve the problem without .split()

So just say you have this in the text:

---------------------------

I love Teemo

Teemo love me

I love Jinx

Jinx love me

------------------------

as we see that there is 4 line above, and I would like the program print only the odd number of the line if the user ask. so the out put only

-------------------

I love Teemo

I love Jinx

-------------------

Also I need to know how if i want the program only print every 6 character from the text and if the character is vocal it print in capital. for example from

------------------

I love Teemo

Teemo love me

I love Jinx

Jinx love me

---------------

it just print

EO mvxlE

and how to

do like this

--------------

Explanation / Answer

# my own split method
def split(string, delim=" "):
result = []
entry = ""
for c in string:
if c not in delim:
entry += c
else:
if entry:
result.append(entry)
entry = ""
if entry:
result.append(entry)
return result

# function to print odd number of lines
def printOdd(data):
# get line by splitting on " "
lines = split(data, " ")
  
# iterate over odd lines and print
# range(start, end, step)
for i in range(0, len(lines), 2):
print(lines[i])

# check if char is a e i o or u
def is_vowel(c):
return c in "aeiouAEIOU"

def print6thChar(data):
result = ""
count = 0
for c in data:
if c == " ":
continue
count += 1
if (count % 6 == 0):
if is_vowel(c):
c = c.upper()
result += c
print(result)

def printCharVowelConsCount(data):
vowel_count = 0
consonent_count = 0
char_count = 0
for c in data:
if c == " ":
continue
char_count += 1
if is_vowel(c):
vowel_count += 1
else:
consonent_count += 1
print("The number of characters: %d" % (char_count))
print("The number of consonants: %d" % (consonent_count))
print("The number of vowels: %d" % (vowel_count))
  

printOdd("I love Teemo Teemo love me I love Jinx Jinx love me")
print6thChar("I love Teemo Teemo love me I love Jinx Jinx love me")
printCharVowelConsCount("I love Teemo Teemo love me I love Jinx Jinx love me")

# copy pastable code link: https://paste.ee/p/6zANv