5
Contributors
10
Replies
11
Views
6 Years
Discussion Span
Last Post by richieking
Featured Replies
  • [CODE]#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()[/CODE] Read More

1
#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()
0

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()
0

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

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.