-2

I will be having different counter value,

if the counter value is 1, I need to use the RequestString as "FirstName=Name1,StreetName=Street1" else if the counter value is 2, I need to use the RequestString as "FirstName=Name2,StreetName=Street2" like this I need to continue

Based on the counter value, I need to get the "RequestString" and use it in the subsequent request. Can any one help how it can be done in python ?

NoBlockhit
  • 369
  • 2
  • 15
Learner
  • 11
  • 3
  • Are you asking this? https://stackoverflow.com/questions/2960772/how-do-i-put-a-variable-s-value-inside-a-string – mkrieger1 Aug 22 '22 at 14:21

1 Answers1

1

If you just want the name of the variables, Name1, Street1, etc. in the request string then you can do this:

def request_from_counter(value):
    return f'FirstName=Name{value},StreetName=Street{value}'

If you want the values of those variables however, then you can do this:

def request_from_counter(value):
    name_value = f'Name{value}'
    street_value = f'Street{value}'
    return f'FirstName={eval(name_value)},StreetName={eval(street_value)}
omermikhailk
  • 116
  • 6