 Introduction to Python

• Status
• 1
Input and Output
• 2
Variables and Integer Arithmetic
• 3
Conditional Operators
• 4
• 5
Types and Variables
• 6
Strings
• 7
Lists
• 8
For Loops
• 9
While Loops
• 10
continue, break, while...else
• 11
String and List methods
• 12
Nested Loops
• 13
List Comprehension
• 14
Tuples and Sets
• 15
dict
• 16
Functions
• 17
Functions 2
• 18
Lambda and higher-order functions
• 19
Files

• # Number digits

Given a number `n = 13453687`, for instance, it’s possible to extract the last digit by taking the remainder when dividing by `10`. We can extract the digit before the last one by dividing the number by `10` and then take the remainder after division by `10`. The digit before that can be extracted by dividing the number by `100` and then taking the remainder after division by `10`, and so on.
``````n = 13453687
print(n % 10)          # 7
print(n // 10 % 10)    # 8
print(n // 100 % 10)   # 6
print(n // 1000 % 10)  # 3
# ...``````

#### Challenge

Given a 4-digit number, print the central two digits.
 Input Output 1234 23 1298 29