-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExcer32.py
More file actions
26 lines (21 loc) · 742 Bytes
/
Copy pathExcer32.py
File metadata and controls
26 lines (21 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Napisz funkcję w Pythonie, aby uzyskać łańcuch składający się z pierwszych 2 i ostatnich 2 znaków z danego łańcucha.
# Jeśli długość ciągu jest mniejsza niż 2, zwróć zamiast tego pusty ciąg.
# Przykładowy ciąg : Python
# Oczekiwany wynik: Pyon
# Przykładowy ciąg : Py
# Oczekiwany wynik: PyPy
# Przykładowy ciąg : P
# Oczekiwany wynik: pusty ciąg
def ret_mangled_string(my_str):
ret_str = ''
if len(my_str) >= 2:
ret_str = my_str[:2] + my_str[-2:]
else:
ret_str = ''
return ret_str
def ret_mangled_string2(my_str):
if len(my_str) >= 2:
return ''
return my_str[:2] + my_str[-2:]
in_str = str(input('Podaj ciąg wejściowy: '))
print(ret_mangled_string2(in_str))