Question

In: Computer Science

Use python There is a revenue list, how to covert it from string to int? Here...

Use python

There is a revenue list, how to covert it from string to int?

Here is the list

['$8,120,000,000', '$8,085,200,000', '$7,703,000,000', '$7,000,000,000', '$5,410,000,000', '$4,212,000,000', '$3,741,400,000', '$3,500,000,000', '$3,000,000,000', '$2,800,000,000', '$2,800,000,000', '$2,529,000,000', '$2,087,600,000', '$2,000,000,000', '$1,900,000,000', '$1,520,000,000', '$1,500,000,000', '$1,500,000,000', '$1,350,000,000', '$1,300,000,000', '$1,400,000,000', '$1,400,000,000', '$1,395,000,000', '$1,200,000,000', '$1,000,000,000', '$1,000,000,000', '$842,000,000', '$887,000,000', '$860,000,000', '$825,000,000', '$799,000,000', '$757,000,000', '$751,000,000', '$701,600,000', '$660,000,000', '$600,000,000', '$577,000,000', '$559,000,000', '$540,000,000', '$532,000,000', '$518,400,000', '$500,000,000', '$500,000,000', '$437,000,000', '$400,000,000', '$350,000,000', '$300,000,000', '$277,000,000'].

Solutions

Expert Solution

Answer:-

Program:-

revenue_list=['$8,120,000,000', '$8,085,200,000', '$7,703,000,000', '$7,000,000,000', '$5,410,000,000', '$4,212,000,000', '$3,741,400,000', '$3,500,000,000', '$3,000,000,000', '$2,800,000,000', '$2,800,000,000', '$2,529,000,000', '$2,087,600,000', '$2,000,000,000', '$1,900,000,000', '$1,520,000,000', '$1,500,000,000', '$1,500,000,000', '$1,350,000,000', '$1,300,000,000', '$1,400,000,000', '$1,400,000,000', '$1,395,000,000', '$1,200,000,000', '$1,000,000,000', '$1,000,000,000', '$842,000,000', '$887,000,000', '$860,000,000', '$825,000,000', '$799,000,000', '$757,000,000', '$751,000,000', '$701,600,000', '$660,000,000', '$600,000,000', '$577,000,000', '$559,000,000', '$540,000,000', '$532,000,000', '$518,400,000', '$500,000,000', '$500,000,000', '$437,000,000', '$400,000,000', '$350,000,000', '$300,000,000', '$277,000,000']
print ("Original list is : " + str(revenue_list))
  for i in range(0, len(revenue_list)):
value= revenue_list[i].replace(',','')
  value=value[1:]
revenue_list[i]=int(value)

print ("Modified list is : " + str(revenue_list))

Output:-

Original list is : ['$8,120,000,000', '$8,085,200,000', '$7,703,000,000', '$7,000,000,000', '$5,410,000,000', '$4,212,000,000', '$3,741,400,000', '$3,500,000,000', '$3,000,000,000', '$2,800,000,000', '$2,800,000,000', '$2,529,000,000', '$2,087,600,000', '$2,000,000,000', '$1,900,000,000', '$1,520,000,000', '$1,500,000,000', '$1,500,000,000', '$1,350,000,000', '$1,300,000,000', '$1,400,000,000', '$1,400,000,000', '$1,395,000,000', '$1,200,000,000', '$1,000,000,000', '$1,000,000,000', '$842,000,000', '$887,000,000', '$860,000,000', '$825,000,000', '$799,000,000', '$757,000,000', '$751,000,000', '$701,600,000', '$660,000,000', '$600,000,000', '$577,000,000', '$559,000,000', '$540,000,000', '$532,000,000', '$518,400,000', '$500,000,000', '$500,000,000', '$437,000,000', '$400,000,000', '$350,000,000', '$300,000,000', '$277,000,000']
Modified list is : [8120000000, 8085200000, 7703000000, 7000000000, 5410000000, 4212000000, 3741400000, 3500000000, 3000000000, 2800000000, 2800000000, 2529000000, 2087600000, 2000000000, 1900000000, 1520000000, 1500000000, 1500000000, 1350000000, 1300000000, 1400000000, 1400000000, 1395000000, 1200000000, 1000000000, 1000000000, 842000000, 887000000, 860000000, 825000000, 799000000, 757000000, 751000000, 701600000, 660000000, 600000000, 577000000, 559000000, 540000000, 532000000, 518400000, 500000000, 500000000, 437000000, 400000000, 350000000, 300000000, 277000000]

If this answer is helpful to you Please Upvote,Thankyou


Related Solutions

C++ bool exists_trio(int*,int); (it must use this line here) I was not sure how to utilize...
C++ bool exists_trio(int*,int); (it must use this line here) I was not sure how to utilize this line because I made code that works but not with this line specifically. //Input:    //an integer array (param 1) and its size (param 2) //Output:    //True or false //Behavior:    //Returns true is there exists    //a sequence of 3 *consecutive* values in the array    //such that the sum of the first two elements    //is equal to the third...
Here is class Dog -String name; -int age -String breed; -boolean adopted; //false if available …………………...
Here is class Dog -String name; -int age -String breed; -boolean adopted; //false if available ………………… +constructor, getters, setters, toString() Write a lambda expression showAdoptable using a standard functional interface that will display the dog’s name age and breed if adopted is false. Help please!!
Write a Python loop that goes through the list and prints each string where the string...
Write a Python loop that goes through the list and prints each string where the string length is three or more and the first and last characters of the strings are the same. Test your code on the following three versions of the list examples: examples = ['abab', 'xyz', 'aa', 'x', 'bcb'] examples = ['', 'x', 'xy', 'xyx', 'xx'] examples = ['aaa', 'be', 'abc', 'hello'].
from typing import List def longest_chain(submatrix: List[int]) -> int: """ Given a list of integers, return...
from typing import List def longest_chain(submatrix: List[int]) -> int: """ Given a list of integers, return the length of the longest chain of 1's that start from the beginning. You MUST use a while loop for this! We will check. >>> longest_chain([1, 1, 0]) 2 >>> longest_chain([0, 1, 1]) 0 >>> longest_chain([1, 0, 1]) 1 """ i = 0 a = [] while i < len(submatrix) and submatrix[i] != 0: a.append(submatrix[i]) i += 1 return sum(a) def largest_rectangle_at_position(matrix: List[List[int]], x:...
Use Python to Load a file containing a list of words as a python list :param...
Use Python to Load a file containing a list of words as a python list :param str filename: path/name to file to load :rtype: list
Using the Python Program. Can an array hold a mixture of types i.e. int, float, string,...
Using the Python Program. Can an array hold a mixture of types i.e. int, float, string, array within the same array? Show a code segment to remove the last element from a 15 element array named myStuff[]. Please explain the code.
USE JAVA PLEASE Use recursion to implement a method public static int indexOf(String text, String str)...
USE JAVA PLEASE Use recursion to implement a method public static int indexOf(String text, String str) that returns the starting position of the first substring of the text that matches str. Return –1 if str is not a substring of the text. For example, s.indexOf("Mississippi", "sip") returns 6. Hint: You must keep track of how far the match is from the beginning of the text. Make that value a parameter variable of a helper method.
Write a Python function that takes a list of string as arguments. When the function is...
Write a Python function that takes a list of string as arguments. When the function is called it should ask the user to make a selection from the options listed in the given list. The it should get input from the user. Place " >" in front of user input. if the user doesn't input one of the given choices, then the program should repeatedly ask the user to pick from the list. Finally, the function should return the word...
python Write a function pack_to_5(words) that takes a list of string objects as a parameter and...
python Write a function pack_to_5(words) that takes a list of string objects as a parameter and returns a new list containing each string in the title-case version. Any strings that have less than 5 characters needs to be expanded with the appropriate number of space characters to make them exactly 5 characters long. For example, consider the following list: words = ['Right', 'SAID', 'jO'] The new list would be: ['Right', 'Said ', 'Jo '] Since the second element only contains...
Here is a list of miscellaneous revenue sources received by governments. Categorize them as best as...
Here is a list of miscellaneous revenue sources received by governments. Categorize them as best as you can as (1) user charge, (2) license tax, (3) franchise fee or (4) Fiscal monopoly, using the standards established in the chapter. Explain your logic. What are the incentive impacts of each one of the revenue sources? A fee for disposal of used ties. A fee to reserve books at the library. A charge for processing the arrest of a convicted drunk driver....
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT