Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Write code using a while loop, that takes a non-empty list of integers from the user, as well as a width. Return a new list
Write code using a while loop, that takes a non-empty list of integers from the user, as well as a width. Return a new list where the original list has been converted into a two dimensional list with the specified width, padded with zeroes at the end as needed. You MAY NOT use any built-in functions/methods besides len() and .append(), you also may not use break statements. Also please use PYTHON 2.7.
Template:
#PROBLEM 1 def chop(l1,w): list1 = l1 width = w #YOUR CODE GOES HERE (indented) return list1 #END YOUR CODE
Test Cases (must work with different test cases also):
chop [] 2 [[0, 0]] chop [1] 2 [[1, 0]] chop [1,2,3] 3 [[1, 2, 3]] chop [1,2,3,4,5,6,7] 3 [[1, 2, 3], [4, 5, 6], [7, 0, 0]]
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