Skip to content

Commit 58282ab

Browse files
committed
add get_list file, readme.md files fix
1 parent c6a4502 commit 58282ab

8 files changed

Lines changed: 31 additions & 28 deletions

File tree

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ print(res_last_name)
116116

117117
age = 18
118118
year_ago = get_year_ago(age)
119-
print(year_ago.strftime('%Y-%m-%d'))
119+
print(year_ago.strftime('%Y'))
120120
```
121121
- program response
122122
```python

create_first_name.py

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
11
import random
2-
import json
3-
import os
2+
import get_list
43

5-
def get_list(path):
6-
if path != "":
7-
path = os.path.dirname(__file__) + "/" + path
8-
return json.load(open(path))
94
#
105
# gender = ['male', 'female']
116
# nationality = ['en', '']
@@ -22,7 +17,7 @@ def first_name_selection(names=[], gender='male', nationality='en'):
2217
#
2318
if __name__ == "__main__":
2419
print ("Start programm play!\n")
25-
fisrt_name = get_list("first_names.json")
20+
fisrt_name = get_list.get_list("first_names.json")
2621
# print(fisrt_name)
2722

2823
res_first_name = first_name_selection(fisrt_name, gender='male', nationality='us')

create_last_name.py

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,5 @@
11
import random
2-
import json
3-
import os
4-
from unicodedata import combining, normalize
5-
6-
def get_list(path):
7-
if path != "":
8-
path = os.path.dirname(__file__) + "/" + path
9-
return json.load(open(path))
10-
#
11-
12-
2+
import get_list
133

144
# nationality = ['en', 'de', 'us', 'ru', 'ua']
155
def last_name_selection(names=[], nationality='en'):
@@ -20,13 +10,11 @@ def last_name_selection(names=[], nationality='en'):
2010
return random.choice(names[nationality])
2111
else:
2212
return "Enter variable \"names\"!"
23-
#
24-
2513

2614
#
2715
if __name__ == "__main__":
2816
print ("Start programm play!\n")
29-
last_name = get_list("last_names.json")
17+
last_name = get_list.get_list("last_names.json")
3018
# print(last_name)
3119

3220
res_last_name = last_name_selection(last_name, nationality='de')

docs/README_DE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ print(res_last_name)
115115

116116
age = 18
117117
year_ago = get_year_ago(age)
118-
print(year_ago.strftime('%Y-%m-%d'))
118+
print(year_ago.strftime('%Y'))
119119
```
120120
- program response
121121
```python

docs/README_RU.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ print(res_last_name)
115115

116116
age = 18
117117
year_ago = get_year_ago(age)
118-
print(year_ago.strftime('%Y-%m-%d'))
118+
print(year_ago.strftime('%Y'))
119119
```
120120
- program response
121121
```python

docs/README_UA.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ print(res_last_name)
115115

116116
age = 18
117117
year_ago = get_year_ago(age)
118-
print(year_ago.strftime('%Y-%m-%d'))
118+
print(year_ago.strftime('%Y'))
119119
```
120120
- program response
121121
```python

get_list.py

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import json
2+
import os
3+
4+
#
5+
def get_list(path):
6+
if path != "":
7+
path = os.path.dirname(__file__) + "/" + path
8+
return json.load(open(path))
9+
10+
#
11+
if __name__ == "__main__":
12+
print ("Start programm play!\n")
13+
14+
fisrt_name = get_list("first_names.json")
15+
print(fisrt_name)
16+
17+
print ("\nEnd programm play!")
18+
else:
19+
print ("An error has occurred! Unable to start")

get_year_ago.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from datetime import datetime, timedelta
1+
from datetime import datetime
22
import random
33

44
def get_year_ago(age):
@@ -13,10 +13,11 @@ def get_year_ago(age):
1313
#
1414
if __name__ == "__main__":
1515
print ("Start programm play!\n")
16+
1617
age = 18
1718
random_date = get_year_ago(age)
18-
# print(f"дата {years_ago} лет назад: {random_date.strftime('%Y-%m-%d')}")
19-
print(random_date.strftime('%Y-%m-%d'))
19+
print(random_date.strftime('%Y'))#%Y-%m-%d
20+
2021
print ("\nEnd programm play!")
2122
else:
2223
print ("An error has occurred! Unable to start")

0 commit comments

Comments
 (0)