minor fixes

This commit is contained in:
Asabeneh 2021-07-10 05:32:09 +03:00
parent 77e0f2db27
commit 8a72b58426
5 changed files with 13 additions and 12 deletions

View File

@ -17,4 +17,5 @@ print(type(1 + 3j)) # Complex
print(type('Asabeneh')) # String
print(type([1, 2, 3])) # List
print(type({'name':'Asabeneh'})) # Dictionary
print(type({9.8, 3.14, 2.7})) # Tuple
print(type({9.8, 3.14, 2.7})) # Set
print(type((9.8, 3.14, 2.7))) # Tuple

View File

@ -373,8 +373,8 @@ print(challenge.index(sub_string, 9)) # error
```py
challenge = 'thirty days of python'
sub_string = 'da'
print(challenge.index(sub_string)) # 8
print(challenge.index(sub_string, 9)) # error
print(challenge.rindex(sub_string)) # 8
print(challenge.rindex(sub_string, 9)) # error
```
- isalnum(): Checks alphanumeric character

View File

@ -58,7 +58,7 @@ fruits[0] = 'Avocado'
print(fruits) # ['avocado', 'orange', 'mango', 'lemon']
fruits[1] = 'apple'
print(fruits) # ['avocado', 'apple', 'mango', 'lemon']
last_index = len(fruits)
last_index = len(fruits) - 1
fruits[last_index] = 'lime'
print(fruits) # ['avocado', 'apple', 'mango', 'lime']
@ -80,7 +80,7 @@ print(fruits)
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.insert(2, 'apple') # insert apple between orange and mango
print(fruits) # ['banana', 'orange', 'apple', 'mango', 'lemon']
fruits.list(3, 'lime') # ['banana', 'orange', 'apple', 'mango', 'lime','lemon',]
fruits.insert(3, 'lime') # ['banana', 'orange', 'apple', 'mango', 'lime','lemon',]
print(fruits)
# remove
@ -92,10 +92,10 @@ print(fruits) # ['orange', 'mango']
# pop
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.remove()
fruits.pop()
print(fruits) # ['banana', 'orange', 'mango']
fruits.remove(0)
fruits.pop(0)
print(fruits) # ['orange', 'mango']
# del
@ -161,10 +161,10 @@ print(ages.index(24))
# Reverse
fruits = ['banana', 'orange', 'mango', 'lemon']
fruits.reverse()
print(fruits.reverse())
print(fruits)
ages = [22, 19, 24, 25, 26, 24, 25, 24]
ages.reverse()
print(ages.reverse())
print(ages)
# sort
fruits = ['banana', 'orange', 'mango', 'lemon']

View File

@ -61,7 +61,7 @@ person = {
'age':250,
'country':'Finland',
'is_marred':True,
'skills':['JavaScript', 'React', 'Node', 'MongoDB', 'Python']
'skills':['JavaScript', 'React', 'Node', 'MongoDB', 'Python'],
'address':{
'street':'Space street',
'zipcode':'02210'

View File

@ -259,7 +259,7 @@ print(randint(5, 20)) # it returns a random integer number between [5, 20] inclu
2. Modify the previous task. Declare a function named user_id_gen_by_user. It doesnt take any parameters but it takes two inputs using input(). One of the inputs is the number of characters and the second input is the number of IDs which are supposed to be generated.
```py
user_id_gen_by_user() # user input: 5 5
print(user_id_gen_by_user()) # user input: 5 5
#output:
#kcsy2
#SMFYb
@ -267,7 +267,7 @@ user_id_gen_by_user() # user input: 5 5
#ZXOYh
#2Rgxf
user_id_gen_by_user() # 16 5
print(user_id_gen_by_user()) # 16 5
#1GCSgPLMaBAVQZ26
#YD7eFwNQKNs7qXaT
#ycArC5yrRupyG00S