-3

I tried writing a code for the collatz func .But somehow i failed in it.i am just sharing the code which i tried.can you figure out the mistake

def my_input():
    a=input("enter:")
    collatz(a)

def myprint(y):
    print(y)
    if (y!=1):
        my_input()

def collatz(number):
    if (number%2)==0:
        return myprint(number/2)
    else:

        return myprint(3*number+1)
my_input()
Austin
  • 25,759
  • 4
  • 25
  • 48
  • 1
    your mistake is most probably `int(input("enter:"))` – Axois Aug 17 '19 at 09:55
  • Are you getting an error? If you are, it is important to read the error message and include it in your post. – Gino Mempin Aug 17 '19 at 09:55
  • @Axois but how do i do that ..do i need to delete my question to close it – neha samala Aug 17 '19 at 10:09
  • @nehasamala You don't need to do anything. Having a question closed as duplicate is not a bad thing. If the answer you got below helped you, you can accept it by clicking on the chek mark below the votes button, but there is no obligation to accept an answer. (And contrary to what some users write: Accepting an answer does not close a question.) – Modus Tollens Aug 17 '19 at 10:13
  • @nehasamala If you still want to delete your question you can click the "delete" link beneath it. – Modus Tollens Aug 17 '19 at 10:16

1 Answers1

0

Your mistake is int(input("enter:")), because you are passing in a string into your function collatz(number), without converting it into int.

Welcome to stackoverflow, next time please include things like your expected outputs or what error you are receiving so that people can easily help you. You can read about how to ask a question here

Axois
  • 1,961
  • 2
  • 11
  • 22