## Thursday, September 24, 2020

Solution exercise 111: python code to create a dictionary from typed text with word as keys and reverses words as values

#### Exercise 111 || Solution

Write a Python program that asks the user to enter a text and return him a dictionary whose keys are the words of the text entered and the values are the reverse of the words that make up the text. Example for the text T = "Python is easy", the program must return the dictionary:
``d = {'Python': 'nohtyp', 'is': 'si', 'easy': 'ysae'}``

#### Solution

``````# ask user to type a text
T = input("Type a some text")
# convert the text to list of words
listWords = T.split(' ')
# create an empty dictionary which will contains the words contained in the text
d= dict({})

for word in listWords:
# creating the reverse of words
reverseWord = word[::-1]
d[word] = reverseWord

# display obtained  dictionary d
print("The obtained dictionary is d = " , d)
# for typed text = "Python is easy", the output is:
# The obtained dictionary is d =  {'Python': 'nohtyP', 'is': 'si', 'easy': 'ysae'}``````

Younes Derfoufi
my-courses.net

## Python Exercises With Solutions

1. Python Arithmetic Exercises
2. Equations & System Of Equations
3. Polynomials and Functions
4. Python Arithmetic Exercises
5. Numpy, Matplolib, Sympy , Scipy - Exercises
6. Python Arithmetic Exercises

Younes Derfoufi

## Sample Text 