Question
Write function called steps that should return a string #that, if printed, looks like this: # #111 # 222 # 333 # #Note that the
Write function called "steps" that should return a string
#that, if printed, looks like this:
#
#111
# 222
# 333
#
#Note that the characters at the beginning of the second and
#third lines must be tabs, not spaces. There should be one
#tab on the second line and two on the third line.
#
#You may only declare ONE string in your function.
#
#Hint: Don't overthink this! We're literally just asking you
#to return one single string that just holds the above text.
#You don't have to build the string dynamically or anything.
#Write function here!
def steps(number):
tabs =0
nums=1
newstring = ''
for i in range(1,number+1):
string = tabs*"\t"+str(nums)*3+' '
tabs+=1
nums+=1
newstring += string
return newstring
#The line below will test your function.
print(steps(3))
We found a few things wrong with your code. The first one is shown below, and the rest can be found in full_results.txt in the dropdown in the top left: We expected steps to return the str "111 222 333". However, it instead encountered the following error: TypeError: steps() missing 1 required positional argument: 'number'
Can you please show me what is wrong with my code and why I'm getting this error. I've tried everything. Thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started