Created
February 6, 2017 23:28
-
-
Save shamikalashawn/fdaea62a3d2b9e008b8251d7ea4c9ee5 to your computer and use it in GitHub Desktop.
A string is collected then each element of the string is turned into a value in a dictionary while its key is its index.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
string = input('Please type in a string.') | |
if type(string) != str: | |
string = input('That is not a string! Please type a string.') | |
else: | |
strindex = range(len(string)) | |
strlist = [] | |
for letter in string: | |
strlist.append(letter) | |
stringdict = dict(zip(strindex, strlist)) | |
print (stringdict) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment