i have one store and 4 customers. lng , lat of store is 50,30 and lists of stores are:
lng_customers= [51,52,53,54]
lat_customers= [35,36,37,38]
I want to make these strings for all of them using a loop.
'your points are/{50},{30};{51},{35}'
'your points are/{50},{30};{52},{36}'
'your points are/{50},{30};{53},{37}'
'your points are/{50},{30};{54},{38}'
how can I make these strings? please help me.
CodePudding user response:
This worked for me:
lng_customers= [51,52,53,54]
lat_customers= [35,36,37,38]
for i, j in zip(lng_customers, lat_customers):
print('your points are/{50},{30}; {%s}, {%s}' % (i, j))
CodePudding user response:
If you need curly braces in your string, this will do the job:
lng_customers = [51, 52, 53, 54]
lat_customers = [35, 36, 37, 38]
string = 'your points are/{{50}},{{30}};{{{}}},{{{}}}'
for lng, lat in zip(lng_customers, lat_customers):
print(string.format(lng, lat))
If not, do this:
string = 'your points are/50,30;{},{}'
for lng, lat in zip(lng_customers, lat_customers):
print(string.format(lng, lat))
Alternatively:
string = 'your points are/{},{};{},{}'
for lng, lat in zip(lng_customers, lat_customers):
print(string.format(50, 30, lng, lat))