Friday, September 11, 2020

python program to accept a group of strings separated by commas as input and display their sum as output

 python program to accept a group of strings separated by commas as input and display their sum as output


 

python program to accept a group of strings separated

  by commas as input and display their sum as output

  ============================================

 

var_list = [ x for x in input('Enter Strings:').split(',') ]

print('The string entered is :',var_list)

 

output:

Enter Strings: John ,Rambo ,Rocky , Balboa

The string entered is :

['John' , 'Rambo' , 'Rocky' , 'Balboa']

 

Here , 4 strings a re passed into the var_list variable

which acts as a storage class for a list object for strings.

The strings specified in the storage have a comma

separator in-between them which separates the list members from one another . The output is a list with the strings as list items in single quotes within the list .

 

 


No comments:

Post a Comment

Durga Puja in Odisha

 Durga Puja in Odisha