-7

Please help me out with the error in the code

a=input("Enter the number:")
kp(a)

def kp(num):
    for i in range(20):
        print(num*i)
Aran-Fey
  • 39,665
  • 11
  • 104
  • 149
Sai
  • 1
  • 1
  • 1
    What's the error you are getting? What are you using as input? – FlyingTeller Mar 26 '19 at 09:26
  • welcome to stackoverflow! please take the [tour](http://stackoverflow.com/tour), read up on [how to ask a question](https://stackoverflow.com/help/asking) and provide a [minimal, complete and verifiable example](https://stackoverflow.com/help/mcve) that reproduces your problem. – hiro protagonist Mar 26 '19 at 09:26
  • @Aran-Fey The wrong order of function call and definition is not the only error in the code, the linked question is therefore not a duplicate – FlyingTeller Mar 26 '19 at 09:33
  • 1
    @FlyingTeller You mean because `a` is a string? That's perfectly valid. It may not be what the OP wants, but we can't say for sure without a [mcve]. I don't think it's worth reopening the question just to close it for a different reason. – Aran-Fey Mar 26 '19 at 09:40
  • sorry messed it up with the string. Now got the output after casting it into an int. Thanks!! @FlyingTeller – Sai Mar 26 '19 at 09:45

1 Answers1

0

You should define your function before its calling:

a=input("Enter the number:")

def kp(num):
    for i in range(20):
        print(num*i)
kp(a)
vurmux
  • 9,420
  • 3
  • 25
  • 45