[Tutor] Code

Dennis Lee Bieber wlfraed at ix.netcom.com
Thu Jul 13 13:14:53 EDT 2023


On Thu, 13 Jul 2023 18:43:18 +0530, hari ganivada
<hariganivada81 at gmail.com> declaimed the following:

>Sir
>
>  I am hari Ganivada.
>   def is _power_off_two(number)
>   number=2
>  while number ? 2==0:
>  number = number/2
> If number == 1:
>    return true
>  return False
>Call to the function
>print(is_power_of_two(0)) # should be False
>print(is_power_of_two(1))# should be true
>print(is_power_of_two(8))#should be true
>print(is_power_of_two(9))#should be false.
>
>Please help me sir

	The most crucial thing is that Python is indentation sensitive. The
code you show above has no consistent indentation and is unusable as shown.
It is missing a : on the "def" line, you have a blank space between "is"
and "_power". I have no idea what character you were trying to put in that
while statement (modulo?). "true" is not the same as "True".

	Don't retype what you think you are running: cut&paste the exact TEXT
(not an image) from your editing window. Do the same with any error
messages you get when trying to run your code.



More information about the Tutor mailing list