Dev 2#3
Conversation
franciscoprin
left a comment
There was a problem hiding this comment.
@Anahis259 or @carlosvivasb could you guys do these changes?
| phone_doesnt_start_with_plus = Phone("+13463335555") | ||
| phone_greater_than_15_characters = Phone("+13463335555321412342134") | ||
| phone_with_special_characters = Phone("!~#$%^&*@|}{") |
There was a problem hiding this comment.
@Anahis259 please remove this. I am curious, why do you think that you have to add these lines?
There was a problem hiding this comment.
Chicos yo me encargo de hacer los cambios donde marque "Aquí"
There was a problem hiding this comment.
ya modifique las ultimas 3 correcciones, las subo...
| phone_keyboard_mapper ={'a':1, 'b':1,'c':1,'d':2,'e':2,'f':2,'g':3,'h':3,'i':3,'j':4,'k':4,'l':4,'m':5,'n':5,'o':5,'p':6,'q':6,'r':6,'s':7,'t':7,'u':7,'v':8,'w':8,'x':8,'y':9,'z':9, | ||
|
|
||
| } |
There was a problem hiding this comment.
Move this dictionary to the helper.py module and then inside of the phone.py file do:
from helper import phone_keyboard_mapper| #""" | ||
| #Should convert letter to digit (see image in the README.md) | ||
| #clue 1: use a dictionary. | ||
| #""" No newline at end of file |
There was a problem hiding this comment.
These lines should be the first one in the method get_number
It is describing what the get_number method is doing.
| #""" | ||
| #Returns the corresponding symbol's string shape using only |, _, -, /, \, | ||
| #Look at the example output in README.md. | ||
|
|
||
| #clue 1: use a dictionary to match the hardcode string with the corresponding symbol. | ||
| #""" |
There was a problem hiding this comment.
Similar than above, this should be the first lines of code of the method get_string, they are describing what the get_string method is doing.
| #def validate_Phone(self) : | ||
| #phone_doesnt_start_with_plus = Phone("+13463335555") | ||
| #phone_greater_than_15_characters = Phone("+13463335555321412342134") | ||
| #phone_with_special_characters = Phone("!~#$%^&*@|}{") | ||
| #Return False |
There was a problem hiding this comment.
Delete these lines of code.
| ] | ||
| } | ||
|
|
||
| print (my_dict[single_simbol]) |
| my_dict ={ "1" : [ | ||
| " ____ ", | ||
| " / | ", | ||
| "/_/| | ", | ||
| " | | ", | ||
| " | | ", | ||
| " _| |_ ", | ||
| " |______|", | ||
| ], "2" : [ | ||
| " _____ ", | ||
| " / __ | ", | ||
| "/__/ / / ", | ||
| " / / ", | ||
| " / / ", | ||
| " / /____ ", |
There was a problem hiding this comment.
You are repeating code here:
The list-numbers are already defined above.
For example
number_one = [
" ____ ",
" / | ",
"/_/| | ",
" | | ",
" | | ",
" _| |_ ",
" |______|",
]
...
# Rest of the numbers
...
number_nine = [
" _______ ",
" / _ |",
"| |_| |",
" \\___ |",
" | |",
" | |",
" |___|",
]
my_dict ={
"1" : number_one,
...
# follow the parent here and write the rest of the numbers.
....
"9":number_nine
}
franciscoprin
left a comment
There was a problem hiding this comment.
@Anahis259, do these changes, please 😄 .
@carlosvivasb, try to understand what changes I am asking to @Anahis259 👀.
| my_dict ={ | ||
| "1" :number_one,, "2" : number_two, "3" : number_three, "4" : number_four, "5" : number_five,"6" : number_six, "7" : number_seven, "8" :number_eight, | ||
| , "9" :number_nine,"0" :number_zero | ||
| } |
There was a problem hiding this comment.
@Anahis259 , you are almost there, Two more changes:
- Break this dictionary into multiple lines
(fewer lines of code no always mean better code, your main focus is that your code is readable.)
my_dict ={
"1" :number_one,
"2" : number_two,
"3" : number_three,
....
# The rest of the lines of code.
....
"8" :number_eight,
"9" :number_nine,
"0" :number_zero,
}- Add a meaningful name for the dictionary.
(my_dictis too vague)
from_num_str_to_num_dict_mapper ={
"1" :number_one,
"2" : number_two,
"3" : number_three,
....
# The rest of the lines of code.
....
"8" :number_eight,
"9" :number_nine,
"0" :number_zero,
}There was a problem hiding this comment.
Just a tiny change @Anahis259 in the name is from_num_str_to_num_dict_mapper nope form_num_str_to_num_dict_mapper 😃
| form_num_str_to_num_dict_mapper ={ | ||
| "1" : number_one, | ||
| "2" : number_two, | ||
| "3" : number_three, | ||
| "4" : number_four, | ||
| "5" : number_five, | ||
| "6" : number_six, | ||
| "7" : number_seven, | ||
| "8" : number_eight, | ||
| "9" : number_nine, | ||
| "0" : number_zero, | ||
| } |
| from helper import my_dict | ||
| from helper import form_num_str_to_num_dict_mapper | ||
| class SymbolFactory: | ||
| def get_string(self, single_simbol): | ||
| return my_dict[single_simbol] | ||
| return form_num_str_to_num_dict_mapper[single_simbol] |
There was a problem hiding this comment.
I am so happy that you realize that you also have to change the imports.

Required enhancements.