<?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>Forem: Debojit Choudhury</title>
    <description>The latest articles on Forem by Debojit Choudhury (@debojit_choudhury_a889561).</description>
    <link>https://forem.com/debojit_choudhury_a889561</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%2F2036356%2F74757737-beb7-4483-aa09-6bcb9f8590b3.png</url>
      <title>Forem: Debojit Choudhury</title>
      <link>https://forem.com/debojit_choudhury_a889561</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/debojit_choudhury_a889561"/>
    <language>en</language>
    <item>
      <title>Fun File Mover Script: From Desktop to Screenshots Folder</title>
      <dc:creator>Debojit Choudhury</dc:creator>
      <pubDate>Sun, 08 Sep 2024 14:59:52 +0000</pubDate>
      <link>https://forem.com/debojit_choudhury_a889561/fun-file-mover-script-from-desktop-to-screenshots-folder-b34</link>
      <guid>https://forem.com/debojit_choudhury_a889561/fun-file-mover-script-from-desktop-to-screenshots-folder-b34</guid>
      <description>&lt;p&gt;Ever felt overwhelmed by the clutter on your desktop? 🌪️ If you're like me, your desktop might be a treasure trove of random files. One common culprit? Screenshots! 📸 They pile up faster than you can say "file management."&lt;/p&gt;

&lt;p&gt;So, I decided to tackle this problem with a fun little script. Here’s how you can move all those screenshots (or any specific file type) from your desktop to a designated folder, all while keeping things neat and organized. 🎉&lt;/p&gt;

&lt;p&gt;What You’ll Need&lt;br&gt;
Python installed on your computer.&lt;br&gt;
&lt;strong&gt;pathlib&lt;/strong&gt; library (comes with Python, so no extra installations required!).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The Script&lt;/strong&gt;&lt;br&gt;
Here's the script that does all the heavy lifting:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;import pathlib&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Set the paths&lt;br&gt;
&lt;em&gt;desktop = pathlib.Path('/Users/91763/Desktop')&lt;/em&gt;&lt;br&gt;
&lt;em&gt;new_path = pathlib.Path('/Users/91763/Desktop/Screenshots')&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Create the destination folder if it doesn't exist&lt;br&gt;
&lt;em&gt;new_path.mkdir(exist_ok=True)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Move all PNG files from the desktop to the new folder&lt;br&gt;
&lt;em&gt;for filepath in desktop.iterdir():&lt;/em&gt;&lt;br&gt;
    &lt;em&gt;if filepath.suffix == '.png':&lt;/em&gt;&lt;br&gt;
        &lt;em&gt;new_filepath = new_path.joinpath(filepath.name)&lt;/em&gt;&lt;br&gt;
        &lt;em&gt;filepath.replace(new_filepath)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Breaking It Down&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting Paths&lt;/strong&gt;: We start by defining the paths for our desktop and the new folder where we want to move our screenshots.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Creating the Folder&lt;/strong&gt;: &lt;em&gt;new_path.mkdir(exist_ok=True)&lt;/em&gt; ensures that our new folder exists. If it doesn’t, it creates one for us.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Finding and Moving Files&lt;/strong&gt;: We loop through each file on the desktop using &lt;em&gt;desktop.iterdir()&lt;/em&gt;. If the file is a PNG (you can change this to any extension you like!), it gets moved to the new folder.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why It’s Cool&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Automation&lt;/em&gt;: No more manually sorting through files.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Organization&lt;/em&gt;: Keeps your desktop clean and your screenshots neatly tucked away.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Simplicity&lt;/em&gt;: The script is straightforward and easy to adapt for other file types or destinations.&lt;/p&gt;

&lt;p&gt;Try this out and watch your desktop transform from a chaotic mess into a model of organization! 🚀 If you have any questions or suggestions, drop them below. Happy coding! 🎉&lt;/p&gt;

</description>
      <category>python</category>
      <category>automation</category>
    </item>
    <item>
      <title>Creating a Simple Adventure CLI Game in Python: Let's Get Coding!</title>
      <dc:creator>Debojit Choudhury</dc:creator>
      <pubDate>Fri, 06 Sep 2024 15:01:05 +0000</pubDate>
      <link>https://forem.com/debojit_choudhury_a889561/creating-a-simple-adventure-cli-game-in-python-lets-get-coding-30ia</link>
      <guid>https://forem.com/debojit_choudhury_a889561/creating-a-simple-adventure-cli-game-in-python-lets-get-coding-30ia</guid>
      <description>&lt;p&gt;Ever thought about building your own adventure game? Well, you’re in luck! In this post, I’ll walk you through creating a super simple text-based game using Python. It's a fun little project where you can flex your coding muscles and have a laugh along the way. No crazy graphics—just you, your creativity, and a bit of code.&lt;/p&gt;

&lt;p&gt;What’s the Game About?&lt;br&gt;
You, the hero, stand before two mysterious doors. One leads to an empty room with a hidden sword, and the other? A fire-breathing dragon! Do you have what it takes to find the sword, defeat the dragon, and claim victory? Or will you meet a fiery end? 😬&lt;/p&gt;

&lt;p&gt;Let’s dive in!&lt;/p&gt;

&lt;p&gt;Step-by-Step Breakdown&lt;br&gt;
Here’s how we can bring this story to life with code.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Ask for the Player’s Name&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;name = input(f"{'Enter Your Name: ':^30}")&lt;br&gt;
print("Welcome, " + name + ", to the land of adventure!")&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The first thing we do is ask for the player's name. You can’t go on a great adventure without a name, right? The input() function lets the player type in their name, and then we give them a warm, heroic welcome.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Making the First Choice: Left or Right?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;print("You are standing in front of two doors. One is to the left and the other is to the right.")&lt;br&gt;
choice = input(f'{"Which door do you want to choose? (left/right): ":^30}')&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The player faces two doors. They get to pick which one to open. Will it be the left or the right? This choice is going to determine their fate, so choose wisely!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. What Happens Behind the Left Door?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;if choice == "left":&lt;br&gt;
    print(f'{"You are in a room with no doors. It is empty.":^30}')&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If the player chooses the left door, they end up in an empty room. It looks boring, but don’t give up just yet! There's something cool hidden here—a sword! 💪&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Finding the Sword&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;if choice3 == "yes":&lt;br&gt;
    print(f'{"You see a sword on the ground.":^30}')&lt;br&gt;
    choice4 = input(f'{"Do you want to take the sword? (yes/no): ":^30}')&lt;br&gt;
    if choice4 == "yes":&lt;br&gt;
        has_sword = True&lt;br&gt;
        print(f'{"You took the sword!":^30}')&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If they decide to look around, they’ll find a sword lying on the ground. This is where they can choose to pick it up or leave it behind. If they grab the sword, a flag has_sword = True gets set, which means they’re ready for battle later!&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;5. Facing the Dragon 🐉&lt;br&gt;
*&lt;/em&gt;&lt;br&gt;
_if choice == "right":&lt;br&gt;
    print(f'{"You are in a room with a dragon!":^30}')&lt;br&gt;
    choice5 = input(f'{"Do you want to fight the dragon? (yes/no): ":^30}')&lt;br&gt;
    if choice5 == "yes":&lt;br&gt;
        if has_sword:&lt;br&gt;
            print(f'{"You defeated the dragon and won the game!":^30}')&lt;br&gt;
        else:&lt;br&gt;
            print(f'{"You were eaten by the dragon and lost the game!":^30}')&lt;br&gt;
_&lt;br&gt;
Eventually, the player needs to face the dragon in the right room. If they remembered to take the sword earlier, they can fight and win! 🎉 But if they skipped the sword, well... it’s game over! 😬&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Wrapping It Up&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;print(f'{"Thank you for playing!":^30}')&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;At the end, no matter what happens, the game says a nice "Thank you for playing!" because we're all winners here (even if the dragon had lunch).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Full Code&lt;/strong&gt;&lt;br&gt;
Here’s the full game in Python:&lt;/p&gt;

&lt;p&gt;name = input(f"{'Enter Your Name: ':^30}")&lt;br&gt;
print("Welcome, " + name + ", to the land of adventure!")&lt;br&gt;
print("You are standing in front of two doors. One is to the left and the other is to the right.")&lt;br&gt;
choice = input(f'{"Which door do you want to choose? (left/right): ":^30}')&lt;/p&gt;

&lt;p&gt;has_sword = False  # Flag to track whether the player has taken the sword&lt;/p&gt;

&lt;p&gt;if choice == "left":&lt;br&gt;
    print(f'{"You are in a room with no doors. It is empty.":^30}')&lt;br&gt;
    choice2 = input(f'{"Do you want to stay here? (yes/no): ":^30}')&lt;br&gt;
    if choice2 == "yes":&lt;br&gt;
        print(f'{"You are still in the empty room.":^30}')&lt;br&gt;
    elif choice2 == "no":&lt;br&gt;
        print(f'{"You are back in front of the two doors.":^30}')&lt;br&gt;
    else:&lt;br&gt;
        print(f'{"Invalid choice. Please choose yes or no: ":^30}')&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;choice3 = input(f'{"Do you want to look around? (yes/no): ":^30}')
if choice3 == "yes":
    print(f'{"You see a sword on the ground.":^30}')
    choice4 = input(f'{"Do you want to take the sword? (yes/no): ":^30}')
    if choice4 == "yes":
        has_sword = True
        print(f'{"You took the sword!":^30}')
    else:
        print(f'{"You left the sword.":^30}')
print(f'{"You return to the two doors.":^30}')
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;while choice != "right":&lt;br&gt;
    choice= input(f'{"Now, you must choose the right door to proceed. (right): ":^30}')&lt;br&gt;
if choice == "right":&lt;br&gt;
    print(f'{"You are in a room with a dragon!":^30}')&lt;br&gt;
    choice5 = input(f'{"Do you want to fight the dragon? (yes/no): ":^30}')&lt;br&gt;
    if choice5 == "yes":&lt;br&gt;
        if has_sword:&lt;br&gt;
            print(f'{"You defeated the dragon and won the game!":^30}')&lt;br&gt;
        else:&lt;br&gt;
            print(f'{"You were eaten by the dragon and lost the game!":^30}')&lt;br&gt;
    else:&lt;br&gt;
        print(f'{"You chose not to fight the dragon and left the room.":^30}')&lt;/p&gt;

&lt;p&gt;print(f'{"Thank you for playing!":^30}')&lt;/p&gt;

&lt;p&gt;Try Adding Your Own Twist&lt;br&gt;
This is just the start! You can tweak the game and add your own ideas. Here are some ways to spice it up:&lt;/p&gt;

&lt;p&gt;Add more rooms with different challenges.&lt;br&gt;
Create extra items for the player to find.&lt;br&gt;
Add puzzles that need to be solved to unlock doors.&lt;br&gt;
Let your imagination run wild! 🎮&lt;/p&gt;

&lt;p&gt;Why It’s Cool to Build a Game Like This&lt;br&gt;
Building a CLI game in Python is a great way to practice coding concepts like loops, conditionals, and user input. Plus, it's fun! Once you get the hang of it, you can start making more complex games, or even dive into something like Pygame for graphical games.&lt;/p&gt;

&lt;p&gt;Conclusion&lt;br&gt;
That’s it! We built a little adventure game with Python. It’s a simple, fun project that anyone can try. So, are you ready to fight some dragons? 🐉 Let me know how your adventure goes!&lt;/p&gt;

&lt;p&gt;Happy coding!&lt;/p&gt;

</description>
      <category>python</category>
    </item>
  </channel>
</rss>
