@@ -161,7 +161,7 @@ To subsitute multiple instances, wrap the right hand side in a Tuple:
161
161
162
162
You can also do variable subsitutions with a dictionary:
163
163
164
- ```
164
+ ``` python
165
165
>> > dict = { " name" : " Mike" , " country" : " Canada" }
166
166
>> > ' I am %(name)s and I am from %(country)s ' % dict
167
167
' I am Mike and I am from Canada'
@@ -428,7 +428,7 @@ get_vowels('gym') # []
428
428
429
429
### Length of Last Word in a string
430
430
This method gets the length of last word in a given string.
431
- ```
431
+ ``` python
432
432
def lengthOfLastWord (self , s : str ) -> int :
433
433
if (s.split()):
434
434
lst= s.split()
@@ -438,14 +438,14 @@ def lengthOfLastWord(self, s: str) -> int:
438
438
```
439
439
### Valid Palindrome
440
440
This method returns a bool value specifying whether a string is palindromic or not.
441
- ```
441
+ ``` python
442
442
def isPalindrome (self , s : str ) -> bool :
443
443
s = [ x.lower() for x in s if x.isalnum() ]
444
444
return s == s[::- 1 ]
445
445
```
446
446
### Check Lowercase
447
447
This method checks if a string is in lower case or not.
448
- ```
448
+ ``` python
449
449
def toLowerCase (self , str ):
450
450
"""
451
451
:type str: str
@@ -455,7 +455,7 @@ def toLowerCase(self, str):
455
455
```
456
456
### Count Negatives in a sorted Matrix
457
457
This method returns the count of negative numbers in a sorted matrix.
458
- ```
458
+ ``` python
459
459
def countNegatives (self , grid : List[List[int ]]) -> int :
460
460
count = 0
461
461
for num in grid:
0 commit comments