Please help me understand where this output comes from when I input just the enter key:
{33: None, 34: None, 35: None, 36: None, 37: None, 38: None, 39: None, 40: None, 41: None, 42: None, 43: None, 44: None, 45: None, 46: None, 47: None, 58: None, 59: None, 60: None, 61: None, 62: None, 63: None, 64: None, 91: None, 92: None, 93: None, 94: None, 95: None, 96: None, 123: None, 124: None, 125: None, 126: None}
<class 'dict'>
Here's my code:
Thank you!
I did notice there are the same number of characters (32) in string.punctuation as there are entries in the dictionary: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ . Do those numbers somehow correspond to those characters?
{33: None, 34: None, 35: None, 36: None, 37: None, 38: None, 39: None, 40: None, 41: None, 42: None, 43: None, 44: None, 45: None, 46: None, 47: None, 58: None, 59: None, 60: None, 61: None, 62: None, 63: None, 64: None, 91: None, 92: None, 93: None, 94: None, 95: None, 96: None, 123: None, 124: None, 125: None, 126: None}
<class 'dict'>
Here's my code:
import string contacts = {} #line = [] count = 0 #continue/stop counter while count == 0: print("To create contacts dictionary, enter <last name>, <first name>, <phone number>. ") rawcntc = input("If done type DONE: ") if rawcntc == "DONE": count = 1 continue #this "if" block works fine... else: #...this "else" block does not. translation = rawcntc.maketrans("","",string.punctuation) #still a string... or evidently not?? print(translation) #debug print(type(translation)) #debugI'm really not understanding the syntax of the translate method. I've gotten "ValueError: the first two maketrans arguments must have equal length" multiple times in trying to figure this out [maybe when typing (",",string.punctuation) rather than ("","",string.punctuation) ].
Thank you!
I did notice there are the same number of characters (32) in string.punctuation as there are entries in the dictionary: !"#$%&'()*+,-./:;<=>?@[\]^_`{|}~ . Do those numbers somehow correspond to those characters?