>>> from string import punctuation
>>> def check_spec_characters(text):
res = [i for i in punctuation if i in text]
if res:
print('YES')
else:
print('NO')
>>> text = 'Expression syntax is straightforward: the operators +, -, * and / work as expected'
>>> check_spec_characters(text)
YES
>>> text = 'Expression syntax is straightforward the operators work as expected'
>>> check_spec_characters(text)
NO
......
if res:
print('Special characters found in text: {}'.format(res))
......
>>> text = 'Expression syntax is straightforward: the operators +, -, * and / work as expected'
>>> check_spec_characters(text)
Special characters found in text: ['*', '+', ',', '-', '/', ':']
>>> symbols_start = '23456789TJQKA'
>>> symbols_heap = 'A926K'
>>> symbols_heap_sort = ''.join(i for i in symbols_start if i in symbols_heap)
>>> symbols_heap_sort
'269KA'
>>> import re
>>> data = ['15', 5, '34k', 'de', '120', 40, 18.6, 've', 'v8', 'v200', 'a10c', 'a5b']
# Выбираем числа и строки, с чисел начинающиеся
>>> numbers_mix = [i for i in data if str(i)[0].isdigit()]
>>> numbers_mix
['15', 5, '34k', '120', 40, 18.6]
# Сортируем
>>> digit = '(\d+)'
>>> numbers_mix_sort = sorted(numbers_mix, key=lambda x: int(re.split(digit, str(x))[1]))
>>> numbers_mix_sort
[5, '15', 18.6, '34k', 40, '120']
# Выбираем оставшиеся строки
>>> text_mix = [i for i in data if i not in numbers_mix]
>>> text_mix
['de', 've', 'v8', 'v200', 'a10c', 'a5b']
#Сортируем
>>> text_mix_sort = sorted(text_mix, key=lambda x: (re.split(digit, x)[0], int(re.split(digit, x+'0')[1])))
>>> text_mix_sort
['a5b', 'a10c', 'de', 'v8', 'v200', 've']
# Итого
>>> result = numbers_mix_sort + text_mix_sort
>>> result
[5, '15', 18.6, '34k', 40, '120', 'a5b', 'a10c', 'de', 'v8', 'v200', 've']
def my_func():
return 'This is my func result'
In [1]: import my_file
In [2]: result = my_file.my_func()
In [3]: result
Out[3]: 'This is my func result'
In [4]: from my_file import my_func
In [5]: result = my_func()
In [6]: result
Out[6]: 'This is my func result'
# my_list = your_list
>>> import itertools
>>> grouped_values = []
>>> my_values = []
>>> value = ''
>>> for _, group in itertools.groupby(my_list, len):
grouped_values.append(list(group))
>>> zipped_values = [list(zip(*i)) for i in grouped_values]
>>> for i in zipped_values:
for u in i:
if len(set(u)) == 1:
value += u[0]
else:
my_values.append(value)
value = ''
break
# for i in my_values: print(i)
решил окончательно, холивары не нужны
while True:
question = int(input('Введите число: '))
# some code
if question == some_value:
break
while True:
question = int(input('Введите число: '))
if question == 1:
print('I am 1')
elif question == 2:
print('I am 2')
elif question == 3:
break
input()
# создаем новый файл math.txt
echo "# Comment " > math.txt
git add math.txt
git commit -m "This is the first commit."
# Вносим изменения в уже существующий math.txt
echo "a=1" >> math.txt
git commit -a -m "This is the second commit."