1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
GREYUIT [131]
2 years ago
5

Write a python program that takes two lists as input from the user, multiplies the index wise elements of the two lists and adds

it to a new variable. While doing the program you should handle the following exceptions: Return an exception if an element in a list is not a number stating “The list has some non number values”. Return an exception if there is an index out of bound stating “Index out of bound”. ============================= Example 1: Input: list_one = [1, a, 2, 4] list_two =[5, 6, 7, 8] Output: The list has some non number values
Computers and Technology
1 answer:
nevsk [136]2 years ago
3 0

Answer:

list_one=[]

list_two=[]

list_three=[]

str1=input("list_one:")

for i in str1:

   if i.isdigit():

       i=int(i)

       list_one.append(i)

   elif i.isalpha():

       list_one.append(i)

str2=input("list_two:")

for i in str2:

   if i.isdigit():

       i=int(i)

       list_two.append(i)

   elif i.isalpha():

       list_two.append(i)

print(list_one)

print(list_two)

if len(list_one)==len(list_two):

   for i in range(len(list_one)):

       multiply=list_one[i]*list_two[i]

       add=str(multiply)

       list_three.append(add)

else:

   print("Index out of bound")

n=0

for i in list_three:

   if i.isdigit():

           n+=1

   else:

       print("The list has some non number values")

print(list_three)

You might be interested in
What would I need to make the perfect music video
Lera25 [3.4K]
To make the perfect music video, you would need a bunch of b-roll and clips that relate to the song. If it’s a slow, relaxing song, you want things that are slow and represent peace. If it’s about something specific, you should have a story behind it to explain. Hope this helps! :)
4 0
2 years ago
Who created the first photograph
Tems11 [23]
Nicephore Niepce created the first photograph.
8 0
3 years ago
Read 2 more answers
Someone help me out eh?
Elodia [21]

Line 4

It should be font-size: 15px

Also there should be curly braces in line 5.

6 0
2 years ago
Read 2 more answers
Given that k refers to a non-negative int value and that t has been defined and refers to a tuple with at least k+1 elements, wr
Rus_ich [418]

Answer:

The expression is "t[k]".

Explanation:

In the question, it is defined that variable k refers to positive integer and variable t refers to a tuple that holds at least k+1 element. The expression for defining the kth element of t is t[k].

  • Where variable t is tuple that collects a sequence of immutable (in-built) Python objects. To define tuple we use the parentheses.
  • The main purpose to use tuple in this question is that it cannot be changed.  

5 0
3 years ago
In his article, “How to Publish Without Perishing,” what does James Gleick believe most people do when they really read a book?
jonny [76]

Answer:

James Gleick believes that they immerse themselves in a rich textual world. The answer is C.

3 0
2 years ago
Read 2 more answers
Other questions:
  • How are a cell's content and format related?
    12·2 answers
  • What is the voltage drop across R4 in the diagram shown above?
    13·1 answer
  • Which one of the following is a correct declaration for a method named passAList that has as arguments an array list myList of s
    8·1 answer
  • Write a statement that toggles the value of the bool variable onoffswitch. that is, if onoffswitch is false , its value is chang
    10·1 answer
  • To rotate text in a cell select the option in the alignment grouping
    9·2 answers
  • This is for being Weird!
    15·2 answers
  • Question 1:
    5·1 answer
  • A collection of wiress connecting the CPU with main memory that is used to identify particular location is called
    13·1 answer
  • Question:
    14·1 answer
  • Define a function that will return the length of a list
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!