-
-
Notifications
You must be signed in to change notification settings - Fork 46.6k
Documentation #8646
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation #8646
Changes from all commits
bbce0e2
9d722a8
527f616
bbf6d4d
840f592
e9de5ec
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -1,3 +1,12 @@ | ||||||||
import string | ||||||||
|
||||||||
"""This function takes two parameters: a string variable named | ||||||||
'key' (with a default value of 'college') and a string variable | ||||||||
named 'pt' (with a default value of 'UNIVERSITY'). | ||||||||
The function returns a string that is a transformation of the 'pt' argument | ||||||||
based on a key-shift cipher""" | ||||||||
|
||||||||
|
||||||||
def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str: | ||||||||
""" | ||||||||
|
||||||||
|
@@ -21,23 +30,30 @@ def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str: | |||||||
""" | ||||||||
key = key.upper() | ||||||||
pt = pt.upper() | ||||||||
temp = [] | ||||||||
for i in key: | ||||||||
if i not in temp: | ||||||||
temp.append(i) | ||||||||
## changed below lines added sets functionality and remove for loops to get unique elemnt in list | ||||||||
temp = list(set(key)) | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is not a documentation change |
||||||||
len_temp = len(temp) | ||||||||
# print(temp) | ||||||||
alpha = [] | ||||||||
# string module can used to generate alphabets list instead of using loops | ||||||||
alpha = list(string.ascii_uppercase) | ||||||||
modalpha = [] | ||||||||
for j in range(65, 91): | ||||||||
t = chr(j) | ||||||||
alpha.append(t) | ||||||||
if t not in temp: | ||||||||
temp.append(t) | ||||||||
for j in alpha: | ||||||||
if j not in temp: | ||||||||
temp.append(j) | ||||||||
|
||||||||
# print(temp) | ||||||||
r = int(26 / 4) | ||||||||
# print(r) | ||||||||
print(r) | ||||||||
print(len_temp) | ||||||||
Comment on lines
+46
to
+47
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Remove these prints
Suggested change
|
||||||||
# for i in range(r*len_temp): | ||||||||
# s = [temp[i] for _ in range(len_temp) if i < 26] | ||||||||
# modalpha.append(s) | ||||||||
|
||||||||
Comment on lines
+48
to
+51
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Along with this random temp code |
||||||||
k = 0 | ||||||||
"""These lines of code creates a dictionary by iterating over the list of | ||||||||
lists. Each letter in the alphabets list is mapped to a letter in a row of | ||||||||
the "modalpha" list. The mappings are stored in the dictionary with the | ||||||||
indices of the alphabets list as keys and the values fromthe corresponding modalpha lists as values""" | ||||||||
Comment on lines
+53
to
+56
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These should be in the forms of comments, not docstrings |
||||||||
for _ in range(r): | ||||||||
s = [] | ||||||||
for _ in range(len_temp): | ||||||||
|
@@ -59,9 +75,10 @@ def mixed_keyword(key: str = "college", pt: str = "UNIVERSITY") -> str: | |||||||
break | ||||||||
k += 1 | ||||||||
print(d) | ||||||||
cypher = "" | ||||||||
for i in pt: | ||||||||
cypher += d[i] | ||||||||
cypher = "".join(d[c] for c in pt) | ||||||||
# cypher = "" | ||||||||
# for i in pt: | ||||||||
# cypher += d[i] | ||||||||
return cypher | ||||||||
|
||||||||
|
||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Firstly, this isn't inside of a function and isn't formatted
Secondly, what does this tell the user that we don't already know? Everything you said is clearly shown by typehints and naming conventions