Teaching Sample
Problem Description
Write a function twins that takes a string as input, and returns a copy of the string where every character is repeated twice
Input: "abc"
Output: "aabbcc"
Input: "a"
Output: "aa"
Input: ""
Output: ""
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:''
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:''
elem
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:'aa'
elem
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:'aa'
elem
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:'aabb'
elem
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:'aabb'
elem
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:'aabbcc'
elem
Sample Solution in Action
def twins(input):
output = ''
for elem in input:
output = output + elem + elem
return output
'abc'
output:'aabbcc'
What went wrong?
def twins(input):
output = ''
for elem in input:
output = elem + elem
return output
'abc'
What went wrong?
def twins(input):
output = ''
for elem in input:
output = elem + elem
return output
'abc'
output:''
What went wrong?
def twins(input):
output = ''
for elem in input:
output = elem + elem
return output
'abc'
output:''
elem
What went wrong?
def twins(input):
output = ''
for elem in input:
output = elem + elem
return output
'abc'
output:'aa'
elem
What went wrong?
def twins(input):
output = ''
for elem in input:
output = elem + elem
return output
'abc'
output:'aa'
elem
What went wrong?
def twins(input):
output = ''
for elem in input:
output = elem + elem
return output
'abc'
output:'bb'
elem
Teaching Sample
By JT
Teaching Sample
- 174