#πŸ”’ Why does it have issues with negative numbers ?

30 messages Β· Page 1 of 1 (latest)

real ridge
#

codewars problem with the following query
Jack really likes his number five: the trick here is that you have to multiply each number by 5 raised to the number of digits of each numbers, so, for example:

my code as follows

def multifply(n):
  return n*(5**len(str(n)))
balmy graniteBOT
#

@real ridge

Python help channel opened

Remember to:

  • Ask your Python question, not if you can ask or if there's an expert who can help.
  • Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
  • Explain what you expect to happen and what actually happens.

:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.

real ridge
#

It's becomes a complex number

#

No more a real number

#

5^(-1) is a complex number

wispy agate
#

!e print(5 ** -1)

balmy graniteBOT
#

@wispy agate :white_check_mark: Your 3.12 eval job has completed with return code 0.

0.2
wispy agate
#

I dont think so

real ridge
#

Oh I see

glossy cradle
#

they probably do not count the - as part of the length

wispy agate
#

5 ** -1 is just (1/5) ** 1

radiant wave
real ridge
#

I see my bad just trying to help

radiant wave
#

!e py def multifply(n): return n*(5**len(str(n))) print(multifply(-9))

balmy graniteBOT
#

@radiant wave :white_check_mark: Your 3.12 eval job has completed with return code 0.

-225
radiant wave
#

oh

#

the minus is counted

#

like etrotta said

#

convert it to the absolute value

real ridge
#

sorry got some good

#

let me read this

#

Yeah minus is counted as a character

#

ohhhh

#

im a silly billy

#

xd

#

thanks ahha

#

!close

balmy graniteBOT
#
Python help channel closed

This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.