How do I solve this problem in python?

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

How do I solve this problem in python?

Post by answerhappygod »

How do I solve this problem in python?
How Do I Solve This Problem In Python 1
How Do I Solve This Problem In Python 1 (321.12 KiB) Viewed 26 times
Earworm2.py 2 1 lyrics = ["I wanna be your endgame", "I wanna be your first string", "I wanna be your A-Team", "I wanna be your endgame, endgame"] 3 lines_of_sanity = 6 4 5 #You may modify the lines of code above, but don't move them! 6 #When you Submit your code, we'll change these lines to 7 #assign different values to the variables. 8 9 #Recall the Earworm problem (3.3.5 Coding Exercise 2). The 10 #first time, you would still finish printing the entire list 11 #of lyrics after lines_of_sanity was exceeded. 12 # 13 #Revise that code so that you always stop when lines_of_sanity 14 #is reached. If lines_of_sanity is 6, you would print 6 lines, 15 #no matter how many lines are in the list. If there are fewer 16 #than 6 lines in the list, then you'd repeat the list until 17 #the number of lines is reached. 18 # 19 #For example, with the values above, you'd print: 20 #I wanna be your endgame 21 #I wanna be your first string 22 #I wanna be your A-Team 23 #I wanna be your endgame, endgame 24 #I wanna be your endgame 25 #I wanna be your first string 26 #MAKE IT STOP 27 # 28 #That's 6 lines: the entire list once, then the first two lines 29 #again to reach 6. As before, print MAKE IT STOP when you're 30 #done. 31 # 32 #HINT: There are multiple ways to do this: some involve a small 33 #change to our earlier answer, others involve a more wholesale 34 #rewrite. If you're stuck on one, try to think of a totally 35 #different way! 36 37 38 #Add your code here! Using the initial inputs from above, this 39 #should print 7 lines: all 4 lines of the list, then the first 40 #two lines again, then MAKE IT STOP 41 lines = 0 Submit Run Grades Reset [Executed at: Wed Jun 1 0:5 1:24 PDT 2022] We found a few things wrong with your code. The first o ne is shown below, and the rest can be found in full_r esults.txt in the dropdown in the top left: We tested your code with ly rics = ["I wanna be your en dgame", "I wanna be your fi rst string", "I wanna be yo ur A-Team", "I wanna be you r endgame, endgame"], lines _of_sanity = 6. We expected your code to print this: I wanna be your endgame I wanna be your first strin I wanna be your A-Team I wanna be your endgame, en dgame I wanna be your endgame I wanna be your first strin MAKE IT STOP However, it printed this: I wanna be your endgame I wanna be your first strin Activ
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply