Isaac H.
asked 12/21/22What would be the output when the following code is executed:
# What would be the output when the following code is executed:
def sample(L, n):
for i in L:
for j in range(n):
print(i[0] * j)
A = ['How', 'are', 'you?']
t = 3
sample(A, t)
More
1 Expert Answer

Aime F. answered 12/21/22
Tutor
4.7
(62)
Experienced University Professor of Mathematics & Data Science
The 'i' will loop over the strings in A, and the 1st letter 'i[0]' of each will be printed 'j' times, yielding the following.
H
HH
a
aa
y
yy
Still looking for help? Get the right answer, fast.
Ask a question for free
Get a free answer to a quick problem.
Most questions answered within 4 hours.
OR
Find an Online Tutor Now
Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.
Judy R.
Hello I am 22 years experienced Online Tutor and Assignment Helper for Computer Science and Math. I have been teaching IT Professionals, students from different grades, and Graduate and Post Graduate students for more than 22 years. I am ready to help you with your learning requirements, assignments, tests, and projects. For further discussion about the assignment or project help you need, please add me on skype and my skype id is nettuitions Thanks01/22/23