Friday, December 20, 2019

Default Arguments - Hacker Rank Solution

In this challenge, the task is to debug the existing code to successfully execute all provided test files.

Python supports a useful concept of default argument values. For each keyword argument of a function, we can assign a default value which is going to be used as the value of said argument if the function is called without it.

Default Arguments - Hacker Rank Solution


2 comments:

  1. set the default argument as none and then before 'for' statement set if condition as
    if stream==none:
    stream=EvenStream()


    because if it is specified as default argument it will be treated as single EvevStream object for all instances of even therefore giving continuous
    0
    2
    4
    6
    8
    10
    for
    even 2
    even 4

    ReplyDelete
  2. set the default argument as none and then before 'for' statement set if condition as
    if stream==none:
    stream=EvenStream()


    because if it is specified as default argument it will be treated as single EvevStream object for all instances of even therefore giving continuous
    0
    2
    4
    6
    8
    10
    for
    even 2
    even 4

    ReplyDelete

Powered by Blogger.