[Python] Ch8. Errors and Exceptions
8.1 Syntax Errors Also known as parsing errors: while True print('Hello world') File "<stdin>", line 1 while True print('Hello world') ^ SyntaxError: invalid...
8.1 Syntax Errors Also known as parsing errors: while True print('Hello world') File "<stdin>", line 1 while True print('Hello world') ^ SyntaxError: invalid...
1. Declaring an Array Array is an object. let arr = new Array(); let arr = []; 2. Adding an Element let fruits = ['orange', 'grape']; fruits[2] = 'lemon'; console.log(fruits) // ['orange', 'gr...
7.1 Formatted String Literals Formatted string literals f: name = 'John' print(f'Hello my name is {name}.') # Hello my name is John. print(f'The value of pi is approximately {math.pi:.3f}.')...
5.1 List Methods list.append(x) Add an item at the end of a list. Same as a[len(a):] = [x] list.extend(iterable) Add a list to the end of a list. Same as a[len(a):] = iterable list.ins...
4.1 for statements Modifying the collection while iterating over the same collection is tricky to get right. Instead: Create a copy. Create a new collection. users = {'Bob': 'active', 'Jo...
Contents 1. Backticks 2. String Length 3. Accessing Characters 4. String are Immutable 5. Lower and Upper Case 6. Substring 7. Comparing Strings 1. Backticks Inside backticks,...
Contents 1. Ways to Write Numbers 2. toString(base) 3. Rounding 4. Imprecise Calculations 5. parseInt and parseFloat 6. Other Math Functions 1. Ways to Write Numbers Different w...
Introduction Javascript enables us to use primitives (string, numbers, etc.) as objects and use methods with it. Primitives can’t use methods directly since they are not objects. Let’s take a look...
Solution Greedy O(n) class Solution: def candy(self, ratings: List[int]) -> int: n = len(ratings) candies = [1] * n for i in range(1,n): if ratings[i] &...
Solution BFS from collections import deque class Solution: def closestMeetingNode(self, edges: List[int], node1: int, node2: int) -> int: n = len(edges) min_dist, res = int...