Write a Python Program to Create a Dictionary From String

Опубликовано: 17 Сентябрь 2023
на канале: Code With TJ
296
4

Hello Programmers, Welcome to my channel.

In this video you will learn about how to Write a Python Program to Create a Dictionary From String

Python Scripts
======================
https://codewithtj.blogspot.com/2024/...

Python Functions Solved
==========================
https://codewithtj.blogspot.com/2023/...

Python Programs Solved
============================
https://codewithtj.blogspot.com/2023/...


Code for word counter
=============================
input_string = input("Enter a String : ")
word_counter = dict()

for word in input_string.split():
if word in word_counter:
word_counter[word] += 1
else:
word_counter[word] = 1

for key, value in word_counter.items():
print(f"{key} has occured {value} times")


Code for char counter
=============================
string = input("Enter String : ")
char_counter = dict()

for char in string:
if char in char_counter:
char_counter[char] += 1
else:
char_counter[char] = 1

for key, value in char_counter.items():
print(f"Letter : {key} has occured : {value} times")

Keywords
=============================
#python #python3 #python_assignment #pythonprogramming #pythontutorial #pythonprojects #pythoncourse #pythonbaba #pythonforbeginners #pythonautomation #pythonbasic #pythonbeginners