8
Last seen 3 years ago
Member for 9 years, 8 months, 2 days
Difficulty Normal
words is passed as a list.
sum variable is set as 0 to count for words found.
for loop is created to iterate through the list of words.
if an element is in text where all strings are in lower case due to the .lower, 1 is added to sum.
sum will return after the loop finishes
More
Uses list comprehension (for loop in one line) where the str variable is checked to make sure letters
are lower case. The for loop iterates through the text if the letter is alphabetic.
Uses module Counter to count items. result contains the highest count by using c.most_common
and returns the first
More
converts the string into to the decimal value based on the radix. there is an exception raised for ValueError when it receives an inappropriate value.
More
converts the string into to the decimal value based on the radix. there is an exception raised for ValueError when it receives an inappropriate value.
More
The function takes a list of alphabetic characters.
count variable will use map to process each of the elements in data with the lambda function. The lambda function will add the count of each character in the list given. After processing each item they are added into a list.
The return will sho
More
List comprehension is being used. The function is placed before the for loop and checks if the row below has pawns which protect the current pawns position number. Columns use chr and ord to convert the letter into a number, reduce the number and convert it back into a letter.
More
for loop splits the coords into row and col and checks if the row behind left and right side has a pawn to defend the current pawn. col uses ord to convert the letter into a number and decrease it by one to get the next lower letter.
More
Loop is created to iterate through the position of the pawns.
is_safe_left will ensure that there is a pawn behind the current pawn on the left side.
is_safe_right will ensure that there is a pawn behind the current pawn on the right side.
ord will allow the program to return to the previous l
More
The function will take the items given.
*args and **kwargs allow you to pass a variable number of arguments to a function.
As long as the length of args is over 0, it will subtract the first value and the last value from the list.
Anything else will return 0.
More
*args and **kwargs allow you to pass a variable number of arguments to a function.
It will subtract the max and min values from the list. Else if the len of the args variable is less than 0 return 0.
More
compares if len -1 is minus n (second value in list). If true returns -1 else returns array[n] ** n
More
compares if len -1 is minus n (second value in list). If true returns -1 else returns array[n] ** n
More
compares if len -1 is minus n (second value in list). If true returns -1 else returns array[n] ** n
More
Converts the text into lower case. Assigns variables. Runs loop and ensure that that character is alphabetic. Compares the text.count with count and if count is lower than text.count() count is updated with text.count(). Returns the letter with the highest count in a string saved in the variable let
More
creates dictionary string and int variables. creates a for loop to iterate through the string
ensures the character is alphabetic and adds it to r a variable. iterates through a variable with a for loop
and adds the value if found in d else it's set as one. orders keys in dictionary
and returns the
More
count variable is created with 0 value
text is passed to be in lower case.
for loop is created to iterate through the words.
if words is found in ltext, find will return -1 if not found, count is added 1.
sum is returned after loop finishes
More
From what i understand this mean the code searchs for alphabetics only and return True else false. A few questions:
How does it count to 3?
What does the {2} mean in the middle?
Why is [a-zA-Z]+ twice in there?...
More
Using lambda. x will contain each element from words. text has two methods using method chaining. text.lower().find(x)>=0 makes text lower case and looks for x in text as long results is over 0. Map applies a function to all the items in an input_list and sums the results.
More
int() will convert the numbers decimal number system. the str_number will define the number to be converted and the radix the numeral system.
More