Question

2 of these blocks of code will produce an error if run. Find each statement with an error in it, describe the error and what

0 0
Add a comment Improve this question Transcribed image text
Answer #1

print("block 1")
str1 = "INST 126 is my first Python course"
print(str1[-6:len(str1)])
list1 = str1.split()
print(list1[len(list1)-1])

print("block 2")
str1 = "INST126"
print(str1[:4]+str(3)+str1[5:])

print("block 3")
groceries = ["eggs","ham","bacon","potatoes","cheese"]
for i in range(5):
item = groceries[i]
print(item)

print("block 4")
cars = ["bentley","honda","porsche","audi","toyota","ford"]
for car in cars:
if "o" in car:
print(car)

print (block 1) tr1 INST 126 is my first Python course print (strl[-6:1en (stri) 1 listit1.split O print (1isti[len (1ist1

block 1 cour3e cour3e block 2 INST326 1 block 3 eggs ham bacon potatoes cheese block 4 honda porsche toyota ford

Add a comment
Know the answer?
Add Answer to:
2 of these blocks of code will produce an error if run. Find each statement with an error in it, ...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT