How to convert a list of words into multiple sentences in python

47 Views Asked by At

Eg: Input: Name: ['FirstName','LastName','FirstNameLastName'] Customer Account Number: ['Customer', 'Account', 'Number', 'Customer Account', 'Customer Number', 'Customer Account Number'] output: FirstNameLastName Customer Account Number

1

There are 1 best solutions below

0
Rubens Kaiserman On

Well if you have a defined pattern to the arrays like:

index 0: first name index 1: last name index 2: fullName

to the first array, and something like it to the second. You can just add the strings together to the output.

There are some ways to do it, using python, usually you'll prefer to use fstrings.

On the exemple you settled would be like this:

output = f'{name[2]} {customer_account_number[5]}'