0

I tried this code:

def multiplyTen(num):
    result = num * 10
    text = "{} multiplied by 10 = {}."
    print(text.format(num, result))

But I got an error: sc of error

The error goes away when I remove the line: print(text.format(num, result)). Why does this line cause such an error? Why doesn't it occur when I put this code outside of a function?

Karl Knechtel
  • 62,466
  • 11
  • 102
  • 153
  • it works with me – Pythoner-sh Apr 02 '23 at 01:14
  • working fine for me – Muhammad Saqlain Apr 02 '23 at 01:14
  • 1
    The problem is caused by mixing and matching tabs and spaces to indent the code. Note that the Stack software **will hide this problem** by automatically converting tabs to spaces in posted code. Please see the linked duplicate to understand the code problem. For future questions, [please do not upload images of error messages](//meta.stackoverflow.com/q/285551) - instead, **copy and paste** a [complete](//meta.stackoverflow.com/q/359146/) exception traceback out of the terminal - starting from the line that says `Traceback (most recent call last):` - and format it like multi-line code. – Karl Knechtel Apr 02 '23 at 01:25
  • Also: please keep in mind that this is **not a discussion forum**. When writing questions, please write only about **the code, not** you, your level of skill, your concerns about posting or anything else about you. Everyone here is expected to follow the Code of Conduct, so there is no reason or need to ask anyone to be nice in the question or to apologize for anything in advance. Just try your best to ask properly as described in [ask]; if there is a problem we can fix, we will fix it; if your help is needed, we will ask you to make whatever edit is needed. We want action, not apologies. – Karl Knechtel Apr 02 '23 at 01:33

0 Answers0