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
Apart from the OOPs concepts learned in this lesson, identify additional concepts and write an essay on their functions. Explain
patriot [66]

Explanation:

Object Oriented Programming (OOPS or OOPS for Object Oriented Programming System) is the most widely used programming paradigm today. While most of the popular programming languages are multi-paradigm, the support to object-oriented programming is fundamental for large projects. Of course OOP has its share of critics. Nowadays functional programming seems the new trendy approach. Still, criticism is due mostly to misuse of OOP.

6 0
2 years ago
Create html code showing heading tags​
kow [346]

Answer:

Assuming you mean the HTML5 head tag, then this may work for you:

<!DOCTYPE HTML>

<html lang="en">

<head>

<title>My Very Awesome Website</title>

<link href="./css/main.css" rel="stylesheet"  />

<meta name="viewport" content="width=device-width, initial-scale=1" />

</head>

<body>

<h1>Hey look</h1>

<p>This is my awesome website!</p>

<h3>Note</h3>

<p>This website is supposed to be 100% awesome!</p>

</body>

</html>

3 0
2 years ago
Complete the following sentence. <br> _______ is often used to solve riddles and puzzles.
Step2247 [10]

Answer:

An answer-key?

Explanation:

I'm sorry but this needs more context, hope this helps a little.

8 0
3 years ago
Read 2 more answers
Which cpu type would most likely be found in a smartphone?.
dlinn [17]

Answer:

dual-core (two), quad-core (four) and octa-core (eight)

Explanation:

These are the most common according to my research.

If I helped you, can I please have brainliest?

Have a great day/night!

4 0
2 years ago
Joshua wants to be a lawyer. He found the following table on the Bureau of Labor Statistics’ website to find out about the emplo
mars1129 [50]

The answer to your question is,

C) The number of lawyers will increase, so it may be difficult to find a job.

-Mabel <3

3 0
3 years ago
Read 2 more answers
Other questions:
  • Savings accounts typically offer more interest than what
    10·1 answer
  • A ____ is text and graphics that print at the bottom of every page.
    12·1 answer
  • What is the meaning for science?
    14·1 answer
  • The_provides access to the internet may also be internal​
    9·1 answer
  • Discuss two advantages and two disadvantages of agile methods.
    6·1 answer
  • How are engineers are related to technology
    13·1 answer
  • Among the following, which is the best protection against ransomware?
    8·1 answer
  • Which of these is an online presentation tool?
    9·2 answers
  • A range check that can be used in Microsoft access to calculate the data collected which is date and time
    10·1 answer
  • Can someone send me reference on communication, importance , communication cycle , pros and cos​
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!