Hướng dẫn count repeated words in a string python - đếm số từ lặp lại trong chuỗi python

Viết mã python để tìm tần số của mỗi từ trong một chuỗi đã cho. Ví dụ:

Input : str[] = "Apple Mango Orange Mango Guava Guava Mango" Output : frequency of Apple is : 1 frequency of Mango is : 3 frequency of Orange is : 1 frequency of Guava is : 2 Input : str = "Train Bus Bus Train Taxi Aeroplane Taxi Bus" Output : frequency of Train is : 2 frequency of Bus is : 3 frequency of Taxi is : 2 frequency of Aeroplane is : 1

Được đề xuất: Vui lòng thử cách tiếp cận của bạn trên {IDE} trước, trước khi chuyển sang giải pháp.{IDE} first, before moving on to the solution.

Cách tiếp cận 1 bằng danh sách (): & nbsp; 

1 Split the string into a list containing the words by using split function (i.e. string.split()) in python with delimiter space.

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']

2. Khởi tạo một danh sách trống mới. & NBSP; Initialize a new empty list. 

3. Bây giờ hãy nối từ vào danh sách mới từ chuỗi trước nếu từ đó không có trong danh sách mới. & NBSP; Now append the word to the new list from previous string if that word is not present in the new list. 

4. Lặp lại trong danh sách mới và sử dụng chức năng đếm (tức là chuỗi.count (Báo chí [Lặp lại])) để tìm tần số của từ ở mỗi lần lặp. Iterate over the new list and use count function (i.e. string.count(newstring[iteration])) to find the frequency of word at each iteration.

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 2

Implementation:

Python3

def freq(str

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0__ Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 strNote: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']4

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']6Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']8

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0__ Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 21Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 strNote: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 24

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 26 Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 21Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 28 Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 10

Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 11Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 12

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0__ Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 21Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 17Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 18Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 19Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 30Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 31Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 32

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 34Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 18Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 36Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 37Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 38Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 30strFrequency of Apple : 1 Frequency of Mango : 3 Frequency of Orange : 1 Frequency of Guava : 2 1

def Frequency of Apple : 1 Frequency of Mango : 3 Frequency of Orange : 1 Frequency of Guava : 2 3

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0____8 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2.

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0freq(__8

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 26 def3Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2def6def7

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0def9

Đầu ra

Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 1

Cách tiếp cận 2 bằng Set (): & NBSP; 

  1. Chia chuỗi thành một danh sách chứa các từ bằng cách sử dụng hàm chia (tức là chuỗi.split ()) trong python với không gian phân cách. & Nbsp;
  2. Sử dụng phương thức SET () để xóa một bản sao và để đưa ra một tập hợp các từ duy nhất & nbsp;set() method to remove a duplicate and to give a set of unique words 
  3. Lặp qua chức năng đếm và sử dụng (tức là chuỗi.count (Báo chí [Lặp lại])) để tìm tần số của từ ở mỗi lần lặp. & Nbsp;

Implementation:

Python3

def freq(str

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0__ Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 strNote: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']4

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']6Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']8

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0__ Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 21Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 strNote: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 24

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 34Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 18):2):3Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 38):5

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 26 Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 21Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 28 Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 10

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0____8 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2.

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0freq(strNote: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']09

Đầu ra

Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 3

Cách tiếp cận 2 bằng Set (): & NBSP;

Python3

Chia chuỗi thành một danh sách chứa các từ bằng cách sử dụng hàm chia (tức là chuỗi.split ()) trong python với không gian phân cách. & Nbsp;

Sử dụng phương thức SET () để xóa một bản sao và để đưa ra một tập hợp các từ duy nhất & nbsp;

Lặp qua chức năng đếm và sử dụng (tức là chuỗi.count (Báo chí [Lặp lại])) để tìm tần số của từ ở mỗi lần lặp. & Nbsp;

____10freq(5Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 strfreq(8

____10str0Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 str2str3

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']44def7

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']47Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']16Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']49

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0__ str6Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 str8

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 26 ):7__12

Cách tiếp cận 3 (sử dụng từ điển):

def Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']11

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']64

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']0Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 26 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']14Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']15Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']16Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']17__12 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']20def7

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']23Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']14Frequency of apple is : 3 Frequency of mango is : 3 Frequency of orange is : 2 Frequency of guava is : 19def7Frequency of guava is : 1 Frequency of orange is : 2 Frequency of mango is : 3 Frequency of apple is : 31__

____10Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 26 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']23Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 22 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']37

Note: string_name.count(substring) is used to find no. of occurrence of substring in a given string. For example: CODE : str='Apple Mango Apple' str.count('Apple') str2='Apple' str.count(str2) OUTPUT : 2 25Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']39Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']40Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']16

Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']50Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']2 Note: string_name.split(separator) method is used to split the string by specified separator(delimiter) into the list. If delimiter is not provided then white space is a separator. For example: CODE : str='This is my book' str.split() OUTPUT : ['This', 'is', 'my', 'book']52

Đầu ra

Frequency of Apple : 1 Frequency of Mango : 3 Frequency of Orange : 1 Frequency of Guava : 2


Chủ đề