{"id":8836,"date":"2021-09-30T14:00:50","date_gmt":"2021-09-30T08:30:50","guid":{"rendered":"https:\/\/python-programs.com\/?p=8836"},"modified":"2021-11-22T18:34:35","modified_gmt":"2021-11-22T13:04:35","slug":"python-program-to-create-a-dictionary-with-key-as-first-character-and-value-as-words-starting-with-that-character","status":"publish","type":"post","link":"https:\/\/python-programs.com\/python-program-to-create-a-dictionary-with-key-as-first-character-and-value-as-words-starting-with-that-character\/","title":{"rendered":"Python Program to Create a Dictionary with Key as First Character and Value as Words Starting with that Character"},"content":{"rendered":"

Interested in programming and want to excel in it by choosing the short ways. Then, practicing with the available Java Program list<\/a> is mandatory.<\/p>\n

Dictionaries in Python:<\/strong><\/p>\n

Dictionary is a mutable built-in Python Data Structure. It is conceptually related to List, Set, and Tuples. It is, however, indexed by keys rather than a sequence of numbers and can be thought of as associative arrays. On a high level, it consists of a key and its associated value. The Dictionary class in Python represents a hash-table implementation.<\/p>\n

Given a string , the task is to create a Python program for creating a dictionary with the Key as the first character and the Value as words beginning with that character.<\/p>\n

Examples:<\/strong><\/p>\n

Example1:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given string = \"hello this is btechgeeks online programming platform to read the coding articles specially python language\"<\/pre>\n

Output:<\/strong><\/p>\n

h ::: ['hello']\r\nt ::: ['this', 'to', 'the']\r\ni ::: ['is']\r\nb ::: ['btechgeeks']\r\no ::: ['online']\r\np ::: ['programming', 'platform', 'python']\r\nr ::: ['read']\r\nc ::: ['coding']\r\na ::: ['articles']\r\ns ::: ['specially']\r\nl ::: ['language']<\/pre>\n

Example2:<\/strong><\/p>\n

Input:<\/strong><\/p>\n

given string = \"this is btechgeeks today is monday and tomorrow is sunday sun sets in the east \"<\/pre>\n

Output:<\/strong><\/p>\n

t ::: ['this', 'today', 'tomorrow', 'the']\r\ni ::: ['is', 'in']\r\nb ::: ['btechgeeks']\r\nm ::: ['monday']\r\na ::: ['and']\r\ns ::: ['sunday', 'sun', 'sets']\r\ne ::: ['east']<\/pre>\n

Program to Create a Dictionary with Key as First Character and Value as Words Starting with that Character<\/h2>\n

Below are the ways to create a Python program for creating a dictionary with the Key as the first character and the Value as words beginning with that character.<\/p>\n