0
0

Project Overview:


Today, did my first coding challenge with a platform designed to enhance coding skills through challenging exercises. As a beginner in the world of coding, I aimed to sharpen my problem-solving abilities and deepen my understanding of programming concepts.

Objective: Are You Playing Banjo?

Create a function which answers the question “Are you playing banjo?”.
If your name starts with the letter “R” or lower case “r”, you are playing banjo!
The function takes a name as its only argument, and returns one of the following strings:
name + ” plays banjo”
name + ” does not play banjo”
Names given are always valid strings.

Code-Wars

The Code

def are_you_playing_banjo():
    name = input("What is your name?")
    if name.lower().startswith("r"):
        print("You are playing banjo!")
    else:
        print("You are not playing banjo!")
are_you_playing_banjo()
Python

Understanding Input Method:

Initially, I crafted a function utilizing the input() method to prompt user input for their name. My code snippet resembled this:

Although functional, this implementation failed to meet the requirements of the coding challenge.

Revised Code:

def are_you_playing_banjo(name):
    if name.lower().startswith("r"):
        return name + " plays banjo"
    else:
        return name + " does not play banjo"
    return name
Python

Insight into Return Statements:

Upon further exploration, I discovered the necessity of utilizing return statements instead of input() to meet the challenge’s specifications. This led to the refinement of my code into a more cohesive and effective form:

The utilization of return statements allowed for a streamlined function that accurately fulfilled the challenge’s criteria.

Learning Experience:

Engaging in this challenge proved invaluable to my learning journey. Through persistent effort and numerous attempts, I encountered a multitude of lessons. One significant takeaway was the importance of meticulous problem analysis and the application of various programming constructs.
Despite the iterative nature of coding challenges, I found immense satisfaction in applying newfound knowledge to craft a functional solution. While my code may still have room for improvement, this experience underscores the significance of perseverance and continuous learning in the realm of programming.

This error message is only visible to WordPress admins

Error: No feed found.

Please go to the Instagram Feed settings page to create a feed.