Skip to content

Commit 88a43cd

Browse files
authored
init: python task
1 parent 6d388f8 commit 88a43cd

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
'''Реализуйте функцию string_or_not(), которая проверяет является ли переданный параметр строкой. Если да, то возвращается 'yes' иначе 'no'
2+
3+
string_or_not('Hexlet') # 'yes'
4+
string_or_not(10) # 'no'
5+
string_or_not('') # 'yes'
6+
string_or_not(False) # 'no'
7+
Проверить то, является ли переданный параметр строкой, можно при помощи функции isinstance():
8+
9+
isinstance(3, str) # False
10+
isinstance('Hexlet', str) # True
11+
Поэкспериментируйте с кодом в интерактивном репле https://replit.com/@hexlet/python-basics-logical-expressions'''
12+
13+
def string_or_not(value):
14+
return isinstance(value, str) and 'yes' or 'no'

0 commit comments

Comments
 (0)