Reputation: 11
i'm doing school project which is calculator of complex numbers. I wrote a function to calculate it but i dont know how to slice input string to make single arguments from it.
It looks like this:
in1: [complex(1.0, 1.0), complex(1.0, 1.0), ’*’, False, ’nazwa’]
in2: [complex(1 , 1), 2, ’+’, True, ’test’]
Its first number, second, operation, and two other arguments. I would like to slice it like:enter code here
number1 = 1.0,1.0
number2 = 1.0,1.0
operation = *
and 2 others. I tried input().split() but it splits it like this : [(complex(1.0 | 1.0) | '*' etc.
Upvotes: 0
Views: 66
Reputation: 1
You can use, input1[index] = input("Your message here") You can also cast the input too into the primitive type you want, such as, input1[index] = int(input("Your message here"))
Upvotes: 0
Reputation: 188
input1 = [complex(1.0, 1.0), complex(1.0, 1.0), '*', False, 'nazwa']
number1 = input1[0]
number2 = input1[1]
noperation = input1[2]
etc
Upvotes: 1