-1

Can someone help me fix the loop (the IDE indicates "unexpected indent" on the first line) and Please suggest be other loops that can be used in the same place

while True:                              
num = int(input(""" Enter Number: """))      
temp = num                                           
numb = temp                                         
zar = 1                                             
print("Develped by Umar Mushtaq")                    
for _ in range(10):                                  
    print(numb, "X", zar, "=", num)             
    num += numb
    zar+= 1
print("Press Ctrl+C To Exit")
TrebledJ
  • 8,713
  • 7
  • 26
  • 48
Ermac
  • 1
  • 1
  • Can you attach your screenshot to the question and provide a little more clarity to your question? The error in your screenshot is about indentation due to the lines within your while loop not being indented. – SteveK Apr 12 '20 at 12:52
  • 2
    Does this answer your question? [What to do with "Unexpected indent" in python?](https://stackoverflow.com/questions/1016814/what-to-do-with-unexpected-indent-in-python) – TrebledJ Apr 12 '20 at 13:07

1 Answers1

0

Your entire code is indented by 1 tab, therefore causing and IndentationError. If you remove those, it will work, like here:

while True:
  num = int(input(""" Enter Number: """))
  temp = num
  numb = temp
  zar = 1
  print("Develped by Umar Mushtaq")
  for _ in range(10):
    print(numb, "X", zar, "=", num)
    num += numb 
    zar += 1 
    print("Press Ctrl+C To Exit")

EDIT: Sorry, misunderstood the question OP was asking. I assume you are making a multiplication facts generator, in which case, here is another way of executing that, in a bit more of a pythony way:

def generate_facts(number, max_number=10):
  return [f"{number} × {i} = {number * i}" for i in range(1, max_number + 1)]

while True:
  number = int(input(" Enter Number: ")) # Still a bit messy, but requires a lot of code to make better, so...
  print(*generate_facts(number),sep="\n")
Robinson
  • 300
  • 3
  • 12