entered = str(input('Enter the string: '))
def check_spec_characters(inp):
symbols = "[ ~`!@#$%^&*()_-+={}[]:>;',</?*-+ ]"
for symbol in symbols:
print (symbol+" in "+inp+" = "+ str((symbol in inp)))
print (check_spec_characters(entered))
config = "1 2 3 4 5 6"
substitutions = {"2":"7", "3":"6"}
def replace_all(text, dic):
for i, j in dic.iteritems():
text = text.replace(i, j)
return text
print replace_all(config, substitutions)
Я беру поле номером 1
O | X | X
----------
| X | O
----------
O | | X
Твой ход. выбери одно из полей (0 - 8): 3
ладно...
O | X | X
----------
O | X | O
----------
O | | X
Я беру поле номером 7
O | X | X
----------
O | X | O
----------
O | X | X
ничья
ничья
class Node:
def __init__(self, value):
self.value = value
self.left = None
self.right = None
def __str__(self):
return self.value
r'''
A-B
\
C - E
\
D
'''
root = Node("A")
root.left = Node("B")
root.right = Node("C")
root.right.right = Node("D")
root.right.left = Node("E")
def iot(node):
if node is not None:
iot(node.left)
print node
iot(node.right)
iot(root)
#каждое условие отдельно
isGreaterThanFive = lambda x: x >5
isSmallerThanTen = lambda x: x<10
# или в виде комбинированого условия
matches_criteria_1 = lambda v: v >5 and v<10
n = 4
if (isGreaterThanFive(n) and isSmallerThanTen(n)):
print "matches"
else:
print "dont match"
v = 9
if (matches_criteria_1(v)):
print "matches"
else:
print "dont match"