Question: solve in python please 2) Define a void function called printAddress. The function will accept one (single!) string as parameter. This string has the format
solve in python please
2) Define a void function called printAddress. The function will accept one (single!) string as parameter. This string has the format of an address: street address, city, province, postal code (items separated by commas). For any string entered as argument, the function will print out the street address, the city followed by the postal code, and the province each on a separate line. How to solve the problem? Use the string method find(...) to find the indices of the commas. Then apply string slicing. The street address is the substring before the first comma. The city is the substring between the first comma and the second comma. The province is the substring after the second comma and before the third comma. The postal code is after the third comma \# find the index of the first comma commalndex = address.find(",") Call and test your function with your own address as string argument
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
