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
IgorC [24]
3 years ago
11

Exercise 9.2.9: Strings To Integers5 points

Computers and Technology
1 answer:
netineya [11]3 years ago
5 0

Answer:

x=input("Enter a String")

def safe_int(x):

   #lis1=[ int(x)if x.isdigit() else 0 for x in list_of_strings]

   lis1=[]

   lis1=x.split()

   print(lis1)

   flag=0

   j=0

   while(j in range(len(lis1))):

       if(lis1[j].isdigit()):

           flag==0

       else:

           flag==1

           try:

               if(int(lis1[j])):

                   lis1[j]=int(lis[j])

               else:

                   flag==1

                   break

           except:

               print("Cannot convert to integer")

       j+=1

   print(lis1)    

   

   

safe_int(x)

Explanation:

We are taking as an input a sentence, and then splitting it into various list items, and storing them in a list. Now we try to convert each item to integer and using try-except print the message cannot convert if its not possible or else converts it. As a check. enter 0 2 7 0   and also try Hello World.

You might be interested in
Suppose you want to view a document that has several headings. what view would you use?
bija089 [108]
Um i think outline. :)
5 0
3 years ago
Convert to binary140
marshall27 [118]

00110001 00110100 00110000

5 0
3 years ago
Which is the most likely reason why scientists change a model?
frozen [14]

C.) New discoveries make the current model inaccurate. Since science is all about observation and experimentation, it is logical that whenever new findings are gathered, scientific models must be modified to adapt to the information. As new ideas and concepts are uncovered, models should be updated to make them correct.

5 0
3 years ago
Read 2 more answers
Please select the word from the list that best fits the definition
Troyanec [42]

Answer

Linguistics

Explanation:

linguistics can be defined as scientific study of language and its structure, including the study of grammar, syntax, and phonetics.

there are some  Specific branches of linguistics  and that include computational linguistics, comparative linguistics, and structural linguistics.

study material into songs can also be defined as a linguistic hence linguistic is the correct option for you question

6 0
3 years ago
Read 2 more answers
Which part of the computer contains logic circuity which interrupts instructions from a program​
poizon [28]

Answer:

The control unit of the CPU contains circuitry that uses electrical signals to direct the entire computer system to carry out stored program instructions.

Explanation: The control unit does not execute program instructions rather, it directs other parts of the system to do so.

6 0
3 years ago
Other questions:
  • Ryan is looking at investment opportunities as a cloud service provider. He wants to invest in a deployment-based cloud model th
    11·2 answers
  • Which of the following describes a hash algorithms ability to avoid the same output from two guessed inputs?A. Collision avoidan
    12·1 answer
  • Write a function called simulate_several_key_strikes. It should take one argument: an integer specifying the number of key strik
    7·1 answer
  • What is the theory of trouble shooting
    10·2 answers
  • Check my work a(n) ________ reference is an automatically created variable that holds the address of an object and passes it to
    15·1 answer
  • Write a program name Dollars that calculates and displays the conversion of an entered number of dollars into currency denominat
    11·1 answer
  • What do you need to do before you can sort and filter data in a data base?
    12·1 answer
  • 27. If X and Y are int type variables,
    14·1 answer
  • I need the answers. i don’t get this
    11·1 answer
  • Does anyone know what episode Hinata threatens useless sakura?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!