Ich würde gerne wissen, ob es eine Möglichkeit gibt, mathematische Symbole in die Funktionsparameter einzufügen.Python Mathematische Zeichen im Funktionsparameter?
def math(x, y, symbol):
answer = x 'symbol' y
return answer
Dies ist ein kleines Beispiel, was ich meine.
EDIT: hier ist das ganze Problem
def code_message(str_val, str_val2, symbol1, symbol2):
for char in str_val:
while char.isalpha() == True:
code = int(ord(char))
if code < ord('Z'):
code symbol1= key
str_val2 += str(chr(code))
elif code > ord('z'):
code symbol1= key
str_val2 += str(chr(code))
elif code > ord('A'):
code symbol2= key
str_val2 += str(chr(code))
elif code < ord('a'):
code symbol2= key
str_val2 += str(chr(code))
break
if char.isalpha() == False:
str_val2 += char
return str_val2
Ich brauche die Funktion einige Male zu nennen, aber manchmal mit einer +/- zum ersten Symbol und manchmal ein +/- für die zweite Symbol
Originalcode:
def code_message(str_val, str_val2):
for char in str_val:
while char.isalpha() == True:
code = int(ord(char))
if code < ord('Z'):
code -= key
str_val2 += str(chr(code))
elif code > ord('z'):
code -= key
str_val2 += str(chr(code))
elif code > ord('A'):
code += key
str_val2 += str(chr(code))
elif code < ord('a'):
code += key
str_val2 += str(chr(code))
break
if char.isalpha() == False:
str_val2 += char
return str_val2
Leider haben Sie ein bisschen mehr –
erarbeiten hast du meine 'answer = x„Symbol“y'? –