Python function not running as expected

Viewed 36

I don't understand what is wrong with my code, it isn't running at all. What am I possibly doing wrong, I am trying to use a function. I have tried changing the number of asterisks but that isn't working, I also tried using quotations.

Here is my code:

def my_function(**h):
  input('Pick a number:')
  print("     ", end="")
  for i in range (1,int(h)+1):
    print("%5d"%i, end="")

  print()
  print("_______"*12)

  for i in range(1,int(h)+1):
    print("%5d|"%i, end="")

    for j in range(1,int(h)+1):
      print("%5d"%(i*j), end="")
  
    print()

Thanks!

1 Answers

I'm not sure what your desired output is, but does this help?

def my_function():
  h = input('Pick a number:')
  print("     ", end="")
  for i in range (1,int(h)+1):
    print("%5d"%i, end="")

  print()
  print("_______"*12)

  for i in range(1,int(h)+1):
    print("%5d|"%i, end="")

    for j in range(1,int(h)+1):
      print("%5d"%(i*j), end="")
  
    print()

my_function()
Related