Blog Archive

search

Wednesday, August 7, 2019

Write a Python program to create two strings from a given string. Create the first string using those character which occurs only once and create the second string which consists of multi-time occurring characters in the said string

PROGRAM:

a = input('Enter a string : ')
dict = {}
c=''
d=''
a=a.rstrip()
for i in a:
    keys = dict.keys()
    if i in keys:
        dict[i] += 1 # insert value in dict and add count
    else:
        dict[i] = 1
     
for (i, j) in zip(dict.values(), dict.keys()):
    if(i>1):
        c=c+j
    else:
        d=d+j
print(c)
print(d)

OUTPUT :


No comments:

Post a Comment

Python program to create a string from two given strings concatenating uncommon characters of the said strings

PROGRAM :  a = input('Enter a string : ') b = input('Enter a string : ') c='' for i in a:     if(i not in b):...