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
ITS MAKING ME TYPE URL CODES NOW!
Oxana [17]

Answer:

You have to the [] and it should work.

Explanation:

Hope this helped!!

6 0
3 years ago
Police officers conducting traffic stops on minority drivers more than non-minority drivers is an example of what?
MAXImum [283]

Answer:

Cultural bias

Explanation:

Certain verifiable studies have been made across the United States of America on traffic stops, which revealed significant cases of cultural/racial bias. Black people were 20 percent more likely to be stopped and searched by the police than white people.  

Within a six-year period, starting from 2011, researchers studied over 100 million traffic stops cases which were carried out by twenty-one state patrol agencies.

7 0
3 years ago
#Write a function called "in_parentheses" that accepts a
zimovet [89]

Answer:

import regex as re

def in_parentheses(a_string):

   regeX = re.compile(".*?\((.*?)\)")

   result = re.findall(regeX, a_string)

   return str(result).replace("[","").replace("]","")

print("test 1: "+in_parentheses("Open ( only"))

print("test 2: "+in_parentheses("This is a sentence (words!)."))

8 0
3 years ago
If you'd like to queue multiple exports and keep working on a different project in Premiere Pro, what method should you use?
pogonyaev

Answer:

Export to Adobe Media Encoder CC only

Explanation:

5 0
3 years ago
Backing up data on a computer means
aleksklad [387]

Answer: when you back data up you are copying it and then moving the copy to another storage device

6 0
3 years ago
Read 2 more answers
Other questions:
  • When using the strcat function, you must be careful not to overwrite the bounds of an array?
    5·1 answer
  • How are the stop lamp bulbs connected in relation to each other? a. In parallel. b. In series. c. In series/parallel. d. None of
    13·1 answer
  • Emma has used copyright works of a number of artists in her photo album and cited all of them except one. She may be caught for
    6·2 answers
  • Se Statements
    6·1 answer
  • Given the following HTML form snippet of markup, which of the following user inputs would meet the regular expression rule writt
    7·1 answer
  • Which SCSI standard allows for the technique known as “hot swapping”? Ultra SCSI Original SCSI Serial SCSI Fast-Wide SCSI
    5·1 answer
  • What is the purpose of using variables in programming?
    11·1 answer
  • How was the Big Ben project similar to the investigation you conducted in class to determine if the table was vibrating? How is
    7·1 answer
  • Write a description about this picture
    13·2 answers
  • What open source format has multiple versions for storing audio and video content?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!