“So erhalten Sie eine Liste von comma getrennten Zeichenfolge in Python” Code-Antworten

wie man einen Input in Python von Comma aufteilt

lst = input().split(',')#can use any seperator value inside '' of split
print (lst)
#given input = hello,world
#output: ['hello', 'world']
#another example 
lst = input().split(' ; ')#can use any seperator value inside '' of split
print (lst)
#given input = hello ; world ; hi there
#output: ['hello', 'world', 'hi there']
Adhun Thalekkara

wie man eine Zeichenfolge oder int mit Komma in Python trennen

 string = input('Input')
    >>> 1,2
    print(cord.split(','))
    >>>['1', '2']
Disturbed Donkey

So erhalten Sie eine Liste von comma getrennten Zeichenfolge in Python

##Write a Python program to input a string that is a list of words separated by commas. 
##Construct  a dictionary that contains all these words as keys and their frequencies as values.
##Then display  the words with their quantities.  

lst = []
d = dict()
user = input ("enter a string ::-- ")
lst = user.split(',')
print("LIST ELEMENR ARE :: ",lst)
l = len(lst)
for i in range(l) :
    c = 0
    for j in range(l) :
        if lst[i] == lst[j ]:
            c += 1
    d[lst[i]] = c
print("dictionary is  :: ",d)
Attractive Addax

Ähnliche Antworten wie “So erhalten Sie eine Liste von comma getrennten Zeichenfolge in Python”

Fragen ähnlich wie “So erhalten Sie eine Liste von comma getrennten Zeichenfolge in Python”

Weitere verwandte Antworten zu “So erhalten Sie eine Liste von comma getrennten Zeichenfolge in Python” auf Python

Durchsuchen Sie beliebte Code-Antworten nach Sprache

Durchsuchen Sie andere Codesprachen