#Please Change the template such that, Create a string that, when printed, #woul
ID: 3719526 • Letter: #
Question
#Please Change the template such that, Create a string that, when printed,
#would put the words one, two, and three each on their own line.
import subprocess
#from answer import *
import sys
def template():
string1 = ""
return string1
#END OF YOUR CODE
test1 = template()
source = open(sys.argv[0],"r")
lines = source.readlines()
source.close()
ctr = 1
Failed = False
while ctr < len(lines) and lines[ctr][:-1] != 'source = open(sys.argv[0],"r")':
line = lines[ctr]
if ('(".index(" in line or ".rindex(" in line' not in line) and (".index(" in line or ".rindex(" in line or ".remove(" in line or ".count(" in line or ".find(" in line or ".split(" in line or ".rsplit(" in line or ".rindex(" in line or ".join(" in line or "sorted(" in line or "min(" in line):
print "ERROR: on line " +str(ctr) + ": "+ line + " you are using a forbidden function or method. You are only allowed to use len(...) and/or .append(...) for this assignment."
Failed = True
ctr += 1
if not Failed and test1 == "one two three " or test1 == "one two three":
print "you got it CORRECT!"
else:
print "we expected one two three , but you got: " + str(test1)
Explanation / Answer
#Please Change the template such that, Create a string that, when printed, #would put the words one, two, and three each on their own line. import subprocess #from answer import * import sys def template(): string1 = "one two three " return string1 #END OF YOUR CODE test1 = template() source = open(sys.argv[0],"r") lines = source.readlines() source.close() ctr = 1 Failed = False while ctrRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.