Def transtoInt (a, b, c) :
Aa=a
Bb=b
Cc=c
A=int (float (aa))
B=int (float (bb))
C=int (float (cc))
Return a, b, c
CodePudding user response:
Why do you want to add float??CodePudding user response:
Because the user may enter an integer, so I want to first converted to a float, then converted to int,CodePudding user response:
The building Lord, how don't work? Work is quite good!def transtoInt (a, b, c) :
Aa=a
Bb=b
Cc=c
A=int (float (aa))
B=int (float (bb))
C=int (float (cc))
Return a, b, c
Print (transtoInt (' 12.3 ', 45.6 ', '78'))
# as a result (12, 45, 78)
CodePudding user response:
(x, y, z)=transtoInt (' 12.3 ', 45.6 '78')The test no problem,
CodePudding user response:
The lack of an output to receive the results returnedCodePudding user response:
You print it, application no problemCodePudding user response:
Program there is no problem, but add a try best to prevent the input cannot be converted to the integerthe condition of the
def transtoInt (* n) :
Try:
N=[int (float (item)) for the item in n [0]]
Return n
Except, ValueError as e:
Print (" failure ")