Advertisements
Advertisements
Question
Observe the following program carefully, and identify the error:
def create (text, freq):
for i in range (1, freq):
print text
create(5) #function callShort/Brief Note
Advertisements
Solution
There are two errors in the given program.
- The function “create” is defined using two arguments, 'text' and 'freq', but when the function is called in line number 4, only one argument is passed as a parameter. It should be written ‘create(5, 4)’ i.e with two parameters.
- The syntax of the ‘print’ function is incorrect. The correct syntax will be ‘print(text)’.
shaalaa.com
Is there an error in this question or solution?
