<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Sunil16666</title>
    <description>The latest articles on DEV Community by Sunil16666 (@sunil16666).</description>
    <link>https://dev.to/sunil16666</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F985359%2F1787b9f9-67f4-4e90-b7db-33e8365a5a08.png</url>
      <title>DEV Community: Sunil16666</title>
      <link>https://dev.to/sunil16666</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sunil16666"/>
    <language>en</language>
    <item>
      <title>Recursive Functions in Python</title>
      <dc:creator>Sunil16666</dc:creator>
      <pubDate>Tue, 06 Dec 2022 14:23:19 +0000</pubDate>
      <link>https://dev.to/sunil16666/recursive-functions-in-python-2ekm</link>
      <guid>https://dev.to/sunil16666/recursive-functions-in-python-2ekm</guid>
      <description>&lt;p&gt;A basic example of a recursive function in python. The function outputs the factorial of &lt;code&gt;num&lt;/code&gt; and ignores additional arguments. If additional arguments are provided, the function returns &lt;code&gt;"ACCEPTING ONLY 1 ARGUMENT"&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The function calls itself over and over until the condition &lt;code&gt;num == 1&lt;/code&gt; is met. Using recursive functions when dealing with repeatable operations is very useful.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="nb"&gt;len&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;args&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="n"&gt;factorial&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;num&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="s"&gt;"ACCEPTING ONLY 1 ARGUMENT"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;GitHub: &lt;a href="https://github.com/Sunil16666/example-code-python/blob/main/Recursive-Factorial-with-ErrorCatching/main.py"&gt;https://github.com/Sunil16666/example-code-python/blob/main/Recursive-Factorial-with-ErrorCatching/main.py&lt;/a&gt;&lt;/p&gt;
&lt;/blockquote&gt;

</description>
      <category>beginners</category>
      <category>python</category>
      <category>programming</category>
      <category>tutorial</category>
    </item>
  </channel>
</rss>
