def main():
      i=input()
      print(i+1)

(I use PYTHON 3.2)

Why i get an error converting message ?

#python 3
def main():
    i = int(input())  #input in python 3 return a string
    print(i + 1)      #now it will add 1 to input     

#Call main() function
main()

or

print(int(i)+1))

after you finish defining the function you have to call the function. here's how

def main():
    #the int() function converts the input to an integer
    i=int(input())
    print(i+1)
#then you have to call the function
main()

and don't forget whenever you use the input() function you have to convert it to an integer if you are dealing with integers and float if you are dealing with float, the default input() gives a string type

e-papa look at my code and your code,it`s has no diffrence.
So read all post better next time.

sorry to call the function, you have to write

main(2)
#for example

This returns 2

Not so fast e-papa!

def main():
    return 'something'

main(2)  # TypeError: main() takes no arguments (1 given)

simple shall we?

def main():
  print(int(input("Number :"))+1)
main()

simple shall we?

def main():
  print(int(input("Number :"))+1)
main()
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.