EBK JAVA PROGRAMMING
9th Edition
ISBN:9781337671385
Author:FARRELL
Publisher:FARRELL
Chapter8: Arrays
Section: Chapter Questions
Problem 5PE
icon
Related questions
Question
python
The program below (left) was supposed to print the output shown on the right but it does not currently. How
you would fix this program so that it prints the desired output? You can only modify one line (and are not
allowed to delete any lines).
Desired output:
1 def some_function():
myList = [ ]
2
3
for val in range(3):
[0]
4
[0, 1]
myList = myList + [val ]
print(myList)
5
[0, 1, 2]
6
7 res = some_function()
Transcribed Image Text:The program below (left) was supposed to print the output shown on the right but it does not currently. How you would fix this program so that it prints the desired output? You can only modify one line (and are not allowed to delete any lines). Desired output: 1 def some_function(): myList = [ ] 2 3 for val in range(3): [0] 4 [0, 1] myList = myList + [val ] print(myList) 5 [0, 1, 2] 6 7 res = some_function()
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Introduction to computer system
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT