in Education by
I have the below string "Halo Device ANumber : 6232123123 Customer ID : 16926" I want to search with the keyword: "62" from the string. Then if I want to show it's whole substring "6232123123" . I am using the below code: string = str('Halo Device ANumber : 6232123123 Customer ID : 16926') ind = string.find('62') word = string.split()[ind] print('62 found in index: ', ind) print('substring : ', word) And getting this output: 62 found in index: 22 substring : Device Select the correct answer from above options

1 Answer

0 votes
by
 
Best answer
If you are looking for the particular "full string", where it ends when there is simply the space, you can just use .find() again: string = str('Halo Device ANumber : 6232123123 Customer ID : 16926') target = '62' ind = string.find(target) ind_end = string.find(' ', ind + len(target)) word = string[ind:ind_end] If you wanted something more robust, we can use regex: string = str('Halo Device ANumber : 6232123123 Customer ID : 16926') word = re.findall('(62\d+)', string).groups()[0] This will take a first match from your string which starts from "62" and captures all the remaining numerical digits. If you want to know more about the Data Science then do check out the following Data Science which will help you in understanding Data Science from scratch

Related questions

0 votes
    I have a List : Old_list =['orders_ce_deduped.01.csv','orders_ce_deduped.02.csv'] I need to get the 01 and 02 part ... = ['01','02'] Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have a set of oil wells compiled in the panda's data frame. It looks like this: wells = pd.DataFrame({'date ... -01-01 FIELDZ 10.8 Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I'm looking through the Apple's Vision API documentation and I see a couple of classes that relate to text ... overview of Vision. Select the correct answer from above options...
asked Jan 30, 2022 in Education by JackTerrance
0 votes
    please see my code below, example_list = [ ['a','b','c'], ['f','g','h'], ['i','j','k'], ] my_string = ''' ' ... g','h'), ('i','j','k'); Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have the string looks like this """PID TTY TIME CMD 1 ? 00:00:01 systemd 2 ? 00:00:00 kthreadd ... related and not with pandas Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    I have the Dataframe column with the following category: data = {'People': ['John','Mary','Andy','April'], ' ... | Science | English | Select the correct answer from above options...
asked Jan 11, 2022 in Education by JackTerrance
0 votes
    Is there any way to split the string if it contains an uppercase letter but not the first letter? For example, ... solution to it? Select the correct answer from above options...
asked Jan 8, 2022 in Education by JackTerrance
0 votes
    Here is my sample string: [true, {"name": "NameofItem", "amount": "1", "price": 100, "sellerName": " ... seem to make that work. Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    Which of this method of class String is used to extract a substring from a String object? (a) ... programming questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    Which of these methods of class StringBuffer is used to extract a substring from a String object? (a) ... questions and answers pdf, java interview questions for beginners...
asked Oct 25, 2021 in Education by JackTerrance
0 votes
    I'm starting with input data like this df1 = pandas.DataFrame( { "Name" : ["Alice", "Bob", "Mallory", ... Any hints would be welcome. Select the correct answer from above options...
asked Jan 28, 2022 in Education by JackTerrance
0 votes
    I have the function and want to create a new column df['growth_factor'] which will have a derived value in it. ... can I achieve this? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have 2 data frames df1 Name 2010 2011 0 Jack 25 35 1 Jill 15 20 df2 Name 2010 2011 0 Berry 45 25 1 ... used the code df1.add(df2) Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    I am from an SQL background was looking for the best way of doing this. c = a.account_id.isin(b. ... above method efficient way? Select the correct answer from above options...
asked Jan 18, 2022 in Education by JackTerrance
0 votes
    Can anyone tell me how do I start Data Science from Scratch? Select the correct answer from above options...
asked Jan 17, 2022 in Education by JackTerrance
...