I'm making a dictionary in which the keys will be one-character symbols separates by a space that the user inputs. I'm assuming that I have call the ord value in a separate line but I'm not sure how to correctly phrase it. Below is the code I have currently:
inp = input()
inp = inp.split(" ")
d = dict.fromkeys(inp, ord(inp))
print(d)
A dictionary comprehension would give you what you want:
This iterates through the string
inpand constructs the key/value pairs from the iterator,x, andord(x).This doesn't remove spaces, as you seem to possibly be after by
inp.split(" "), but I interpreted this as your attempt to split the string by character. Should you want to remove spaces, remove them from theinpobject.