Nathan Zilora
hacker

@21natzil (625)
A repl.it discord and repl talk moderator! I love bit manipulation and I'm interested in cyber security and data science.
14
Weekly Repls #35
Welcome back everyone! I hope everyone is having a great day! For those in the U.S, happy memorial day. My calendar says it's also Spring Bank Holiday in the UK, so maybe someone can tell me in the comments what that's about. However you guys came here for the awesome repls of this week, so let's show them! @uint9000_t [Makes a web app to help you make some super sweet graphs!](https://repl.it/talk/share/Visualize-the-Golden-Ratio-and-more/15011) @programmyBoi [Created their own OS, that includes quite a few things!](https://repl.it/talk/share/programmyOS/14955) @Eyseedoubleyou [Have a really long conversation, with this very chatty program!](https://repl.it/talk/share/Conversation-Simulator-V10/14942) @HENRYMARTIN4 [Play a minecraft-like game, inside your browser!](https://repl.it/talk/share/WebCraft-A-Online-Minecraft/14899) @jajoosam [SPOngebobifY AlL Your TEXT USiNG THIS weB ApP!](https://repl.it/talk/share/SPongebob-AS-a-SERVICe/14890) @HarperframeInc [Made their own terminal client, send messages to your friends using the program! A very nice client aswell.](https://repl.it/talk/share/TermiMail-A-90s-User-Friendly-Mail-Application/14886)
12
posted to Announcements by 21natzil (625) 21 days ago
23
Weekly Repls #33
Welcome back everyone! We had a lot of events going on, such as the discord server's code jam. The results of that have yet to be posted, however I have a feeling that they'll be coming out soon... Anyways, you're not here to learn about the jam. You're here for this week's repls, so let's check them out! @CowNationz [Creates a wonderful, easy to use database in C++, lightweight and can easily display it's tables.](https://repl.it/talk/share/MooDB-A-lightweight-database-program/14307) @timmy_i_chen [Created an entertaining game for all to play! Flip switches until you create the correct combination.](https://repl.it/talk/share/Byte-The-Game/14229) @eankeen [Explains how to create your own blog setup, all inside of repl.it!](https://repl.it/talk/learn/Blogging-on-Replit-with-Hexo/14074) @lukel_lv [Through the new Love 2D language on repl.it, play asteroids to explode all of space.](https://repl.it/talk/share/Asteroids-game-made-with-Love2D/14066) @TristanArmstron [Play a simple, but really fun game of cows and bulls, where the objective is too find a 4 digit combination, with a variety of small hints.](https://repl.it/talk/share/Cows-and-Bulls/14124) That's all for this week. I can't wait to see what you guys make next week!
0
posted to Announcements by 21natzil (625) 1 month ago
9
Weekly Repls #34
Welcome back repl.it-ers. Actually, I have a received a request that we should be called replitears. I really like that name, so from now on I hereby declare that repl.it users are called replitears! Now it's time for the repls, replitears. @niorg2606 [Creates a site that allows you to add some pizzaz to your *own* repl.it websites!](https://repl.it/talk/share/ReplTheme-Sparkle-your-web-REPL-up-a-bit/14528) @A5rocks [Compilers, can be tricky, thankfully repl.it compiles it for you. However if you ever wanted to change your compiling settings, checkout this tutorial.](https://repl.it/talk/learn/Using-Custom-Compiler-Switches/14487) @FellowHashbrown [Creates a great tutorial, explaining how to create the Quine-McCluskey Algorithm in python!](https://repl.it/talk/learn/Python-Quine-McCluskey-Algorithm/14461) @bossotron13 [Creates a great reaction time calculator, that stores the results for a leaderboard!](https://repl.it/talk/share/Reaction-time/14392) Thats all *replitears*, have a great week! (Also, happy mothers day, even if I'm a bit late)
15
posted to Announcements by 21natzil (625) 1 month ago
9
Making a discord bot with disco-py (not discord.py!)
# Creating a discord bot with disco-py This is **not** a discord.py tutorial! This is a tutorial for a discord bot library that I prefer, and made by one of discord's own developers! [disco-py](https://github.com/b1naryth1ef/disco). ## Getting Started First, let's create a [python3 repl](https://repl.it/languages/python). We're going to create a requirements.txt file, can put the following text inside it. ``` disco-py flask ``` Repl.it will look to this file for external dependencies, disco-py for bot obviously, and flask, if you want to use uptimerobot. Then we're also going to create a folder for the plugins called `plugins`. Plugins are exactly like discord.py's cogs, it's just a set of commands grouped together, that can be loaded / unloaded. By now you should have created a bot application [here](https://discordapp.com/developers/applications), and you can now copy the bot's token. Now create a `.env` file, and write ``` token=<token here> ``` `.env` files are special on repl.it, as other people can't see them. Repl.it will load these files on startup and create environment variables. Alright, now time to write some code! ## Creating a plugin! Let's create a file in the plugin folder called `hello.py` (`plugins/hello.py`) and create the class that will hold all the commands / listeners. ```python from disco.bot import Plugin class HelloPlug(Plugin): ... ``` We'll get into loading the plugins later (For those of you that've used discord.py, you'll notice there's no function like `setup` to add the plugin. That's because disco-py doesn't need one.) Let's create a command that says hello to us. ```python from disco.bot import Plugin class HelloPlug(Plugin): @Plugin.command("hello", "<name:str...>") def hello(self, event, name: str): event.msg.reply(f"Hello {name}!") ``` Ok, let's break down all this code. First we use `@Plugin.command` to tell disco that this function is a command. The first argument we pass into that in the name of the command that people will use to invoke the command. The second argument specifies what information the command requires. The syntax is pretty simple, however it requires an explanation. * The `<` `>` characters specify that this argument is required. If I had used `[``]`, it would have been optional. * `name:str` tells disco-py to pass the value provide into the function's `name` argument. the `str` tells disco-py to cast the value to a string, if it's not already. * The `...` tells disco-py to match the whole input. Without this, if someone did `!hello Johny Jenkins`, name would only be `Johny`. * `command("add", "<num1:int> <num2:int>")` will match `!add 5 4` * `command("kick", "<user:str> <reason:str...>")` will match `!kick Johny Called me ugly` * **Pro Tip:** You cannot use `...` if it's not the last argument. As you can see, an `event` variable is provided, this will contain information on the event, and exposes things such as * event.msg * event.channel * event.author * event.guild In this case, we want to send a message back in the same channel, so we can do `event.msg.reply` for that. If you've used discord.py, you'll notice we're not using async / await. That's because disco-py uses the (arguably better) gevent lib. This means you can use packages such as requests, almost any database driver, and still be asynchronous! ## Running the bot Disco-py has a very different way of running bots, for better or worse. We're going to create a `config.json` file. Here we're going to put information like the prefix and plugin locations. The config.json actually stores a lot more information, but for right now that's all we'll need. ```json { "bot": { "plugins": [ "plugins.hello" ], "commands_prefix": "!" } } ``` You can copy paste this, it's pretty self-explanatory. Don't use `/` or `\\` paths to provide the location of the bot, instead use `.` like you're importing it. Now, disco bots must be run by the command line, but doing something like: ```bash python3 -m disco.cli --token <token here> ``` **Pro Tip**: Make sure you run this command in the same directory as the config file However that's quite inconvenient on repl.it. Instead, we're going that some command in the main.py file, like so: ```python from os import environ, system token = environ['token'] system("python3 -m disco.cli --token {token}".format(token=token)) ``` And at this point, we have everything we need! You can start the repl and everything should be ready to go! This is just a small part of disco-py. Sadly, the docs right now are quite lacking. That's why I'm going to continue to work on this tutorial, and expose all of disco's hidden treasures! You can view the complete bot here: https://repl.it/@21natzil/ExampleBot ## Using it with uptimerobot (Optional) If you'd like to run your bot on repl.it, it's actually even easier with disco-py than discord.py. disco-py has flask integration built right in, making it super easy to combine a website and discord bot. Let's return to the `hello.py` file, and add the following route to the Plugin class: ```python @Plugin.route("/") def index(self): return "Hello World" ``` If you've used flask before, this should look very familiar. All this code does is return the text `Hello World` when someone visits the website. Now we just have to edit the config, and add 2 pits of information flask requires. ```json { "bot": { "plugins": [ "plugins.hello" ], "commands_prefix": "!", "http_enabled": true } } ``` All we added was `"http_enabled": true` to tell disco-py that we're using flask. And just like that if you visit the repl's website it should say `Hello World`! See the link to the example bot above to see it in action. Thanks for reading! Hopefully you'll give disco-py a try. At first glace it's not much, but I promise you, it's much more complicated then that! Any feedback or questions are greatly appreciated!
0
posted to Learn by 21natzil (625) 22 days ago
Pinned
2
Weekly Repls #36
Welcome back everyone! Sorry it took so long, we'll be back to a normal schedule in no time. Let's checkout the amazing posts I've been missing out on. We have a new challenge, and will require a lot of creativity. Keep in mind, we won't be posting your challenge submissions here, just posts in Learn and Share. Now let's see this repls! @timmy_i_chen [Created an awesome demo of python, and library that makes game development incredibly easy!](https://repl.it/talk/share/Physics-Fun-with-Python-Play/15481) @wayanjimmy [Created a linked-list model in typescript!](https://repl.it/talk/share/Linked-List-in-Typescript-using-Closure/15437) @malvoliothegood [Created a tutorial to help teach people PHP, a language repl.it just added!](https://repl.it/talk/learn/PHP-tutorial-No-1-Introduction/15442) @enigma_dev [Is showing people how to use R to train your computer!](https://repl.it/talk/learn/Machine-learning-for-beginners-in-R-1Introduction-to-KNNand-Reading-data-from-a-dataset/15323) That's all folks, see you guys next week!
5
posted to Announcements by 21natzil (625) 6 days ago
11
Weekly Repls #31
Woah, no weekly repls last week? Yep, sorry everyone, I was away. However do not fear, for I'll make up for it today. How you might ask? By showing you a whole bunch of awesome, and some of them famous, posts made by you guys! Let's not wait any longer, here are this week's repls. @kspgaming2006 [Shows us how to make games using repl.it's new pyxel language.](https://repl.it/talk/share/Not-So-Snake-Game/13512) @mat1 [Mat opens a new realm of possibilities, releasing a program that is more than a game. It's a way of life.](https://repl.it/talk/share/full-blockfull-block-Empty-full-blockfull-block/13315) @eankeen [This post went quite unnoticed, despite it's amazing content. Use this repl to view all questions on repl talk, with a very nice interface.](https://repl.it/talk/share/Replit-Talk-Post-Fetcher/13505) @cloud9c [Checkout this amazing six sided civilization / age of empires game!](https://repl.it/talk/share/HexaWar/13486) @a_siebel [Shows us how to use a really awesome wrapper on pygame! I highly suggest anyone that has used pygame in the past, check this out.](https://repl.it/talk/share/Miniworldmaker/13299) @Scoder12 [Via the power of websockets, checkout this program to sync your repls, and have them work together!](https://repl.it/talk/share/Coordinate-your-repls-with-WebSockets-up-down-arrow/13280)
6
posted to Announcements by 21natzil (625) 2 months ago
Python
Python
30
Pokemon Name Generator!
# How to use & What it is ![image](https://storage.googleapis.com/replit/images/1547931949724_af479074e7156a7834adf40b9377b1eb.pn) This is a pre-trained AI, that creates new Pokemon names based off a list of around 800. The code is actually really, stupidly simple thanks to the all powerful textgenrnn library which you can find [here](https://github.com/minimaxir/textgenrnn). If you would like to train it yourself, fork it and delete all the files that start with textgenrnn. If you want it to create more realistic names, you should change the `num_epochs` value to something higher. Granted, this means it will also take longer to train. # What I learned Even with this small amount of code, you learn a lot about AI. The first thing being what works as data. I was originally making an AI from my spam emails, however with only 15 emails, the AI was generating gibberish with no sign of improving. After training with pokemon names, 800 of them, the progress it was making was becoming much clearer. The problem with pokemon names is that it's a single word. The textgenrnn lib works much better with sentences, and because of this I had a very high ***loss*** ratio. Loss is just a number that's used to show how different the AI's output is, to the input or some other determining factor. Lastly, temperature determines how extreme the AI's Pokemon names are. A low temp means less creative but more accurate, high is the opposite, and usually more fun! # Did it work? Yes, and no. I think I was able to create an AI that did learn, for example you'll see that early on the AI is using vowels anywhere, but eventually keeps them in the center of names, which is how most Pokemon names are. In addition, it *very* quickly learned not too use caps letters at the beginning, and only at the beginning. However it's really impossible to grade how it did. Pokemon names are random gibberish already, so it can make anything and it'll sound just fine. ### But go on! Run the repl and see what names it makes for you!
6
posted to Share by 21natzil (625) 5 months ago
9
Weekly Repls #32
*Snap* And just like that, half of all repls cease to exist... just kidding! Not even Thanos would want that. Instead, Thanos and the avengers want the weekly repls, so that's just what I'll do! Here's a challenge for this week, make an avengers themed repl (But no spoilers!!!) @RobotScorpion [Has a great idea, and does a great job implementing it. Put your security cameras online, and have website visitors report crimes on cams to win rewards!](https://repl.it/talk/share/CrowdcamOnline/13757) @JesseMalnik [Creates a very simple AI, without the use of tensorflow and such!](https://repl.it/talk/share/Neural-Network-Class-in-Python/13713) @sojs [Watch as balls bounce around in a space without gravity on this mesmerizing site.](https://repl.it/talk/share/Bouncy-Balls/13655) @SPQR [Utilizing repl.it polygott feature, you can get games such as minecraft running on repl.it (though, not well)](https://repl.it/talk/share/Minecraft-on-Replit/13590) @ItsEmpCs [Simulate your hacking experience in this idle clicker game!](https://repl.it/talk/share/A-great-Hack-the-world-idle-game/13591) See you all next week!
3
posted to Announcements by 21natzil (625) 2 months ago
Python
Python
27
Import other repls!
Through the power of a new module I made called `rimp`, you can import your repls and other people's repls in python. ![image](https://storage.googleapis.com/replit/images/1545860515746_202d14fe853df63097cffa34081367ae.pn) * If you want to see an example of how to use rimp, see below. * If you want to see the source or know how to make your repl compatible with importing, [click here](https://github.com/Zwork101/rimp)
14
posted to Share by 21natzil (625) 6 months ago
18
Code Jam Results!
# Repl.it code jam (Make an OS) Now disclaimer, our participants did not make an operating system such as Windows, OS X, or some linux distribution. They had 48 hours to develop an "OS" that had a login, a file system, and could run some programming language. The submissions were great, and I enjoyed scouring every last one of them. Everyone made something super unique and I'm exited to share them with you. ## Let's backup. What is a code jam? A code jam is an event that occurs on the [repl.it discord](https://repl.it/discord) guild. Members from all ethnicities and ages come to build a project around some theme. The theme is announced the day it starts, this time it was *Build an OS*. However you can't just make whatever you want. While that would be super fun, each submission is graded by a moderator, and it would be hard to compare one OS that sends jokes and another that's serious. The requirements are as follows. * ***FILE SYSTEM***: Every OS must have some way to create directories and files, and be able to navigate between them. * ***CODING***: Every OS must have some way to not only write code to a file, but also run code from a file. * ***LOGIN***: Every OS must be able to login to an account. In addition, there were fields that weren't required, however a good OS will have them. * ***INTERFACE***: The interface is how nice the OS displays information and takes in input. * ***EOO***: EOO stands for *Ease of Operation*. This grades how easy an OS is to use. * ***DOCS***: Documentation is very important, I'm not a mind reader, so it's almost essential an OS has this. * ***EXTRAS***: Anything else that the OS has, like being able to read stuff from google, would give people a point. All of the listed categories can be scored up to 5, so a submission could have a total of 35 points max. You can view the 0-5 grades as *Didn't include, Exists, Functional, Good, Nice!, Perfect!* This year people built their projects by themselves, however we've done team jams before. ## Now let's get into the top 5! * (5) We have (repl.it: [@JosephGrace](https://repl.it/@JosephGrace) / discord: @Tunnelbridge#8408) with [WTOS](https://repl.it/@JosephGrace/JAMMMMMM). The only one out of the top 5 submission to use C++, and created an OS that was very easy to use! They had a great file system, however I just wish more effort was put into the interface. * (4) We have (repl.it: [@Harmeet_SinghSi](https://repl.it/@Harmeet_SinghSi) /discord: ♓S#1624) with [DRONE](https://repl.it/@21natzil/AquaRuddySystemadministrator-S1624). A wonderful example of an OS in the web browser. They did a fantastic job with running and writing to files. And the file system was super awesome. Unforchanetly, after tackling such a huge project, bugs were bound to happen. And they really took a toll on major parts of the OS. * (3) We have (repl.it: [@ThatSmart](https://repl.it/@ThatSmart) / discord: JackFly26#8835) with [JackUX](https://repl.it/@21natzil/FifthCodeJam-JackFly268835). This OS was easy to use, with no glaring issues. Especially things like the file system, login, and docs. Could have made their own editor, however the one they had was more than functional. Also, uses polygott, so if you don't know what that is, check it out this submission! * (2) We have (repl.it: [@FelixMattick](https://repl.it/@FelixMattick)/ discord: archmaster#6356) with [Sys.X](https://repl.it/@21natzil/SysX-archmaster6356). This submission is just amazing, and really highlights the talented people repl.it is proud to host! They had both a website, and a terminal version for their OS. Multiple programming languages you could choose to use, the main being JS. Wonderful interface, with great colors. They had a whole selection of extra features, the only critique would be to work on making it easier to operate. * (1) Last, but not least, we have (repl.it: [@pyelias](https://repl.it/@pyelias)/ discord: elias#7990) with [BomOS](https://repl.it/@21natzil/Jam5-elias7990). It was close, but elias, a previous jam winner, just came through with an OS that's chock full of content. With colors to identify files from directories, custom programming languages, did I mention the all the commands, were *written in the custom programming language*! It was very impressive, and I highly suggest people check it out. ## What's next? I enjoyed the theme, and I picked it because I saw an influx in people making operating systems in Repl Talk. Who knows what the next theme will be 😊. People were asking if they could work with partners this time, so we might try that again. The moderators will also work harder to create a better grading system, because if you were in previous jams, you may have noticed that this year's grading is quite different. We're trying new things, so we can optimize your fun! Having the public vote for projects was also suggested, however we've found a few issues with that. The first problem being that we can't ensure people are graded fairly, we don't want this to become a popularity content. The second reason being cheating. People can create alternative accounts, and have those accounts vote for them. It's possible we try this out in the future however, we're open to all suggestions. If you have any suggestions, you can contact me on the repl.it discord (@Zwack010#0001).
13
posted to Announcements by 21natzil (625) 5 months ago
11
Weekly Repls #29
Sorry, no weekly repls for today. See you guys next week! ... Alright just kidding, how could I resist to show off all these amazing projects! Plus, we already did an April Fools day prank on the *"Ocaml.it DIscord Server"*, so no need to do one here too. Enough of the pranks, lets finally show off this week's repl highlights! @Lord_Poseidon [A while back, we announced this game, but it was hidden in a message. Now that it's announced, here's a tutorial on how you could have solved that puzzle!](https://repl.it/talk/learn/How-I-solved-the-Secret-Announcement/12577) @21natzil [Scheduling events can be hard, especially when they need to happen in a long amount of time. ActionDB solves that issue!](https://repl.it/talk/share/New-Action-lib-Persistent-gevent-scheduler/12486) @glench [To make developing games easier, this person made python play, a wrapper on pygame to make game developing super easy!](https://repl.it/talk/learn/Announcing-Python-Play-beta-and-a-pong-game-tutorial/12430) @smrsan761 [Made a very impressive Tetris game, with no external libraries, runs very smoothly!](https://repl.it/talk/share/Tetris-without-canvas/12433) @Scytherbar [Makes an easy to use chatroom client, colorful and all!](https://repl.it/talk/share/Chat-Room-Online/12372)
2
posted to Announcements by 21natzil (625) 3 months ago
12
Weekly Repls #24
Good Morning (or evening) everyone. No long weekend this week, but that's all right. You guys used those extra days of vacation to make some really awesome stuff! So without further a due, let's check these repls out!. @AZRIELGIESWEIN [Ever wanted to start your programs with large, ascii text! Write any sentence into this program, and see the cool text that comes out!](https://repl.it/talk/share/Ascii-Typer/10975) @leon332157 [jsonstore.io is a pretty sweet site, and this python lib lets you interact with it, with ease!](https://repl.it/talk/share/NEW-Python-Lib-for-wwwjsonstoreio-DONT-LOOSE-YOUR-DATA-AGAIN-WITH-JSON-STORE-NEW/10956) @GrantKeo [Cleaning your room may seem like a chore, however this program tries to turn it into game, and succeeds!](https://repl.it/talk/share/Life-o-a-Hoarder-Console-Edition/10982) @theangryepicbanana [Through the mathematical power of the Julia language and sixels, sketch all your equations, in the terminal!](https://repl.it/talk/share/Sixels-in-Julia/10985) @amasad [Uses a AI model (really, the brain) from OpenAI to generate complete, albeit zany, paragraphs!](https://repl.it/talk/share/Open-AI-GPT-2-language-model/10998) @TheDrone7 [Want a nice looking website, where you can display all your projects, goals, and achievements? Check out this great template!](https://repl.it/talk/share/Making-your-own-portfolio/11046) @mkhoi [While a simple program, this did make me laugh when I saw it and I wanted to include it](https://repl.it/talk/share/A-old-timeys-style-of-a-website/11054)
10
posted to Announcements by 21natzil (625) 4 months ago
11
Weekly Repls #28
What, the weekly repls came out early?!?! Crazy I know, but don't worry, any super awesome repls posted later today will be added to next week. This week however we saw a lot of people experimenting with the new graphic capabilities, and are a great source for inspiration. And remember, if you don't see your challenge submission on here, that's because weekly repls only cover the share and learn boards. Now, let's see what you guys made! @Game_Collabs [Created a fantastic program that turns images into ascii, with color!](https://repl.it/talk/share/Image-to-Ascii/12296) @udaygoyat45 [Using the new swing java support, watch pixels create animated blobs in Conway's game of life.](https://repl.it/talk/share/Michael-Conwayss-Game-of-Life/12262) @neodymium [Watch as circles fight to survive against the squares, in this amazing simulation!](https://repl.it/talk/share/Natural-Selection-Simulator/12203) @PYer [The prize for the game jam is 1 btc, but how much is 1 btc? This repl will show you the price, live!](https://repl.it/talk/share/Live-Bitcoin-Value/12200) @TimothyAnderso1 [This person choose to push the limits of repl.it, and decided to run OpenGL in a pygame repl, and it turned out great!](https://repl.it/talk/share/3D-Cube-In-OpenGL-Python/12195) @malvoliothegood [With the power of processing.js, watch as an oddly satisfying animation of a cat make your day.](https://repl.it/talk/share/Processingjs-spinning-cat/12060) @superwhiskers [PyPy is a JIT compiler for python, and offers usually faster speeds. Though polygott, get it installed, and running on your repl!](https://repl.it/talk/share/pypyrepl-python35-compatible-pypy-on-replit/11968)
1
posted to Announcements by 21natzil (625) 3 months ago
13
Debugging in python, fun and easy!
# Debug Without Errors Debugging is the most dreaded part of programming. It should just work! And sometimes bugs can lead to hours of extra work. However they don't need to be, and by following some of the steps presented in this guide, hopefully you'll be able to fight your next bugs with vigor and valiance! In this tutorial, we'll be using [this program, which is intentionally broken](https://repl.it/@21natzil/Debug-Example). Follow along and make the changes we talk about, and see it be fixed right before your eyes! (Don't try to figure out what it does, it just does random things). Alright, so when we run this program we get... ``` The max number cannot be 0 The max number cannot be 0 The max number cannot be 0 The max number cannot be 0 ``` Oh no! We didn't even get an exception! Where do we even begin? Forchanetly, this program is very small. However for larger projects this is a huge issues. A smart place to start, would be the line that displays the output. In this case, it's ```py except: print("The max number cannot be 0") ``` Now, in this program we only want this error to be raised in the max_number is 0! Clearly, the condition that must be met to trigger this line is wrong. The condition in this scenario is a try-except case, with no defined exceptions! This is bad code 101, also define what exception you want to catch, else wise python will catch all of them. Plus, the message doesn't need to be in a try-except statement. We can create an if-statement at the start of the function, where is the max number is 0, it will print the message and exit the function. If we remove the try-except statement and add the if statement, the function will look like this: ```py def handle_math(min_number: int, max_number: int): if max_number == 0: print("The max number cannot be 0") return print( get_data() * int(min_number / max_number) ) return (min_number / max_number) ``` Great problem solved and if we run that... ``` The max number cannot be 0 The max number cannot be 0 The max number cannot be 0 The max number cannot be 0 ``` What? We just fixed this error! Why is it still here? Don't panic, we know it's not the try-catch anymore. Think about it reasonably, this means that the code calling the function is calling it wrong, so let's take a look at it. ```py numbers = [0, 1, 2, 3] for i in range(len(numbers)): r = handle_math(5, numbers[i]) numbers.insert(0, r) ``` This is a great time to use the *rubber duck* technique. The idea is you read out your code to a rubber duck, although the rubber duck is optional. So let's do just that, we make a list, create a range from 0-3, call `handle_math` with 5 and the item in the list at an index from 0-3. Then we update the items in the list by adding the result of handle_math to the start of the list. Did you catch the error? Maybe we should visualize what's happening. The list when we start looks like the this with`i` being 0. |Items:| 0 | 1 | 2 | 3 | |--------|---|---|---|---| |Index:| **0** | 1 | 2 | 3 | The `handle_math` we return None, because the value passed in was 0. Then None is added to the start of the list, and then the loop increments `i` so it's now `1`, however now the list looks like: |Items:| N | 0 | 1 | 2 | 3 | |--------|---|---|---|---|---| |Index:| 0 | **1** | 2 | 3 | 4 | As you can see, the 0 moved up, and so it's index is `1`. The *range* generator doesn't compensate for that, and so `i` will always be `0`. To fix this, instead of iterating the index, let's iterate through each element in the list, which will look like: ```py numbers = [0, 1, 2, 3] for i in numbers.copy(): r = handle_math(5, i) numbers.insert(0, r) ``` *Phew*, we're finally done! Now if we run this we'll get: ``` The max number cannot be 0 Traceback (most recent call last): File "main.py", line 22, in <module> r = handle_math(5, i) File "main.py", line 15, in handle_math get_data() * (min_number / max_number) File "main.py", line 7, in get_data return resp.content.decode('ascii') UnicodeDecodeError: 'ascii' codec can't decode byte 0x81 in position 4: ordinal not in range(128) ``` Oh no, another bug! When will it end. Don't fret, we're actually making progress, and we can locate the current error with more ease! The problem now is this error message is super complicated. `'ascii' codec can't decode byte 0x81 in position 4: ordinal not in range(128)`? What does that even mean? Errors like these are can be intimidating, but through the power of google, we will prevail! If you simply paste your exception into google, the first site is a [stackover flow post](https://stackoverflow.com/questions/21129020/how-to-fix-unicodedecodeerror-ascii-codec-cant-decode-byte) which has a response that goes into great detail. If we read that, we'll realize that the issue is we're decoding bytes into ascii, which can't represent all the values in our data. Instead, we should use uft-8, which can handle all these values. Now that function looks like: ```py def get_data(size=16): with requests.Session() as session: with session.get(f"https://httpbin.org/stream-bytes/{size}") as resp: return resp.content.decode('utf-8') ``` Wew, nice! Now that we've done our research, we should be in the clear right? Running our code now gives us: ``` The max number cannot be 0 <<<<< << < ``` Which is actually what we wanted! We're done! *I know, this looks random and trust me it is, I just needed a broken program*. I hope you learned much about debugging, and maybe I'll make a follow up using `pdb` if this is well received. [You can find the finished, debugged version here.](https://repl.it/@21natzil/Debug-Fixed) ## Have a great day!
2
posted to Learn by 21natzil (625) 4 months ago
7
Weekly Repls #30
Wow, week thirty and we're still going strong! Thanks to you guys, who keep producing amazing content. Without you, we wouldn't have anything to share, and we could be able to inspire nearly as many people! So thank you, and now let's get to the repls. @polytrope [Created a wonderful, in-depth tutorial on making fractals in js, great for all the math or js fans out there!](https://repl.it/talk/learn/Julia-Fractals-in-JavaScript/12806) @ArchieMaclean [Is starting a wonderful series on using Django on repl.it. While most repls use flask now, it's great way to start learning another, just as powerful, web framework.](https://repl.it/talk/learn/Learning-Web-Development-with-Python-Part-1/12880) @VijaySingh1 [Checkout some of the most popular python libraries out there in this tutorial, which explains what they are, and how to use them!](https://repl.it/talk/learn/6-Essential-Python-Libraries-for-Python-Programming/12677) @JULIANBERRYESSA [Created an awesome prebuilt template for you discord.js bots! Fork the project, and then start building your bot immediately!](https://repl.it/talk/share/Advanced-DiscordJS-Bot-Template/12795) @malvoliothegood [Shows us how to utilize the power of react, with this simple and sweet example](https://repl.it/talk/share/animals-list-using-react-hooks/12727) @theangryepicbanana [Created their own programming language, LineLang! The syntax consists of only, you guessed it, lines!](https://repl.it/talk/share/LineLang/12648) Awesome posts, and we'll see you all next week!
2
posted to Announcements by 21natzil (625) 2 months ago
Python
Python
7
New *Action* lib! Persistent gevent scheduler!
Action isn't your normal database, as it doesn't wait for you. It *comes*. Basically, action lets you create a events that will be spawned later. Even better, these events are saved to disk, and if they didn't execute, they will be executed the next time you setup the lib. Checkout the demo below if interested. GitHub: https://github.com/Zwork101/actiondb Docs: https://zwork101.github.io/action/ Enjoy!!!
3
posted to Share by 21natzil (625) 3 months ago
13
Weekly Repls #13
Hello everyone! Little late but do not fear! Repl.it man is here! By the way, how do you guys pronounce repl.it? Do you say repEL or repUL? Comment below! @Badvillain01 [Ever wondered how to make a REST API with python? This person made a great tutorial, utilizing Flask!](https://repl.it/talk/learn/How-to-make-Rest-Api-in-Python/9038) @mat1 [Impresses us once again with his awesome Sixel library! Watch as a (somewhat laggy) yet moving globe turn across the terminal!](https://repl.it/talk/share/SPINNING-GLOBE-GIF-WITH-SIXEL-NEW/9139) @DrankArizonaIce [While in beta this game, looks, STUNNING! You can't do much, but there's so much potential I can't wait to see what they do with this next](https://repl.it/talk/share/GAME-ENGINE-DEMO-Townsend-Build-Defend-and-Grow-your-colony-of-tiny-people/9121) @TMH97 [Speaking of games this week, this game is simple, yet a lot of fun! The progression of difficulty is amazing, and you should really give it a try!](https://repl.it/talk/share/Dodge-the-Blocks-game/9119) @IEATPYTHON [Started a new series on repl.it, called POTW! They just posted the challenge results which you can find here, so stay tuned for more!](https://repl.it/talk/share/POTW-2-Sunflowers/9199) I addition to great posts, you guys have also created an influx in questions, which is awesome. Have a great week everyone!
7
posted to Announcements by 21natzil (625) 6 months ago
11
Weekly Repls #19
I wonder if the following submissions were made by AI... I guess we'll never know. However I see that the AI challenge has begun, and while the weekly repls won't cover posted made for the challenge, I'll be sure to checkout every repl you guys post. With that out of the way, let's check out these posts! @Vandesm14 [Join Vandesm as they test the limits of node.js!](https://repl.it/talk/share/Just-how-fast-is-NodeJS/9982) @minermaniac447 [Meet Eim, A game that is most defiantly not Uno, doesn't play like Uno, and most *definitely* isn't as fun as Uno (or is it?)](https://repl.it/talk/share/Ein-A-Copyright-Infringement-Free-Uno-Clone/9994) @jajoosam [Impresses us once again, with their program that connects to your Spotify account and returns instrument only versions of your playlists!](https://repl.it/talk/share/Make-an-instrumental-version-of-your-Spotify-playlist/10051) @rshetty [Amazes us with this online pokemon game, interact and social with your friends in this game!](https://repl.it/talk/share/A-multiplayer-open-source-Pokemon-MMO-that-runs-right-in-your-browser/9971) @tristanbeedell [Add colors to your program, and this repl shows off all the colors you can use!](https://repl.it/talk/share/Terminal-Colours/9978) @SPQR [Thanks :D](https://repl.it/talk/share/replit-staff-appreciation-post/9968) That's all. Remember, submit your repls for the AI challenge, but don't forget to share your other, sweet projects!
3
posted to Announcements by 21natzil (625) 5 months ago
9
Weekly Repls #22
Heyyyyyy everyone! I hope you guys all had a great weekend, and a great last week. The challenge is over, so I can't wait to see how you guys did! Lots of awesome projects there, and here! So without further a due, let's see what you guys made! @Vandesm14 [Brings to light an older game, refurbished and plenty of fun, can you solve the combination?](https://repl.it/talk/share/Lock-Picker-Terminal-Edition/10564) @minermaniac447 [Ciphers are a cool way to send secret messages to your friends, and this cipher program *nq xweqche!* (seed: hkujyb)](https://repl.it/talk/share/CipheRot/10649) @themaka [Posted a very relaxing, and zen program which simply has bubbles bouncing around. The code is great for those looking into canvas however!](https://repl.it/talk/share/Some-chill-relaxing-bubbles/10685) @mat1 [In the midst of an intense subscriber count war, Mat creates a live subscriber count of PewDiePie](https://repl.it/talk/share/Live-PewDiePie-sub-count/10689) @17ivanovk [Created a wonder and in depth RPG! Easy to play and with great combat.](https://repl.it/talk/share/Loa-RPG/10638) See you all next week!
4
posted to Announcements by 21natzil (625) 4 months ago
10
Weekly Repls #20
Wow, we've reached the 20th week, and seen so many wonderful repls. In that time we've had a variety of projects, challenges, and code jams to go along with it. Let's celbrate this week by showing off some repls that were posted! @Geocube101 [Shares a very unique game with us. Imagine the scene in "Indiana Jones" where there's a boulder rolling towards him, but as a game](https://repl.it/talk/share/Yet-Another-Blocky-Game/10098) @Scoder12 [Shared us a great tutorial / projects that highlights how to make multiplayer games with web sockets!](https://repl.it/talk/share/LIVE-Multiplayer-Game-Template-With-WebSockets/10238) @Hacker22 [Is trying to make a program that identifies trash, recyclables and compost, but needs the repl.it community for examples!](https://repl.it/talk/share/Crowdsourcing-Array-for-Recycling-Machine-Learning-Project/10247) @danielk [Created a dangerous repl, not for the faint of ram. Run this repl IF YOU DARE](https://repl.it/talk/share/The-Destroyer-of-Web-Browsers/10296) That's all this week. Don't forget to share what you're working on, along side your AIs! Cya!
2
posted to Announcements by 21natzil (625) 5 months ago
12
Weekly Repls #11
Hello everyone! We've been watching all your great bots in the challenge, and seeing them in action on the discord server. If you haven't joined yet, you can join it [here](https://repl.it/discord). While the bots are being looked at and graded, let's take a break and look at some awesome posts this week. @theangryepicbanana [stuns us by breaking down the boundaries of xterm. They made a WIP xterm drag-n-drop](https://repl.it/talk/share/Experimenting-with-mouse-events-in-the-terminal/8665) Also, see their [art drawer](https://repl.it/talk/share/Painting-app-in-the-terminal/8699) that utilizes this. @Reader8765 [Make a game with some out of this world drifting! It's a very simply game, but it really is fun to fly around with great acceleration mechanics](https://repl.it/talk/share/Space-Game/8693) @pyelias [A Mandelbrot set, simply put, is a pattern with infinitely looping patterns inside it. Although you can't see the sub-patterns in this ASCII display, it's neat none the less](https://en.wikipedia.org/wiki/Mandelbrot_set) @nithilan4 [Storing data is not always as easy as it may seem, and using google sheets isn't the easiest database to work with. Despite this, this person made a great game with it, that you should checkout!](https://repl.it/talk/share/Highscores/8801) Have a great week everyone, catch ya next time 😉
8
posted to Announcements by 21natzil (625) 7 months ago
7
Weekly Repls #27
Helloooo jammers! How is everyone doing? I hope you're all having fun messing around with all the new graphical languages are just came to repl.it. I can't wait to see what games you guys make for the challenge. Remember, just like weekly repls in the past, I will not be sharing repls from challenge. So make sure to share some other things you're working on it be showcased here! With that out of the way, let's see who made some awesome repls. @GarethDwyer1 [Published this truely indepth tutorial, on how to scrape websites that use rss, and returning cloudwords from it! I highly recommend you check it out!](https://repl.it/talk/learn/Building-Word-Clouds-from-the-News-using-Python-and-Replit/11653) @christianbm1 [Play a fun, 1 player game of battleship. How long will it take you to eliminate the targets?](https://repl.it/talk/share/Battleship-Game/11648) @PushprajNaik [Created a wonderful way to scrape song names off amazon music!](https://repl.it/talk/share/webscrap/11817) @Russell23 [Brings the excitement of DVDs hitting the bottom right corner to you browser, showing off a great use of pygame!](https://repl.it/talk/share/Improved-DVD-logo/11946) That's all folks. See ya next week!
0
posted to Announcements by 21natzil (625) 3 months ago
14
Weekly Repls #5
Welcome back to the 5th week of awesome repls! It seems like just yesterday we started this series. And do we have some repls for you! @Kaldisberzins [made an improved version of his pathfinder that marks dead ends in a different color - fascinating to watch!](https://repl.it/talk/share/Pathfinder-II/7416) @DrankArizonaIce [created a simple Shakespearean markov chain!](https://repl.it/talk/share/Shakespeare-Wrote-Plays-And-Hes-Dead-Simple-Markov-chain-implementation/7440) @amasad [Created this awesome load-balancer, showing off how you can split a website's load!](https://repl.it/talk/share/Round-robin-load-balancer-with-other-repls-as-backends/7435) @Fhillis [made Breakout using only vanilla JS, no libraries!](https://repl.it/talk/share/BREAKOUT/7386) @tristanbeedell [Really impressed us with this awesome 3D shape render-er. The amount of work put into this is awesome, I 100% wish for you to check it out!](https://repl.it/talk/share/3D-Renderer/7551)
4
posted to Announcements by 21natzil (625) 8 months ago
15
Weekly Highlights #4
Welcome back everyone! I hope you all had a great week! Remember, we have the learn challenge going on right now, and I highly suggest you check that out. With that said, here are come cool projects with week! @DavideRosa [created an online GUI editor for Python using REMI - export to a python file to add functionality!](https://repl.it/talk/share/Experimental-online-GUI-Editor/7126) @Four_Of_Clubs [is showing us how much fun adventure games can be. Ignore the a couple of spelling issues, and this game is really fun, I'd suggest you try it!](https://repl.it/talk/share/First-Adventure-Python/7122) @GarethDwyer1 [Ever wanted the scour the web? Mine all it's precious data? Well thanks to this well made tutorial, now you can!](https://repl.it/talk/learn/Beginner-web-scraping-with-Python-and-Replit/7218) @kaldisberzins [Path finding is an important part of mathematics and algorithms are constantly competing to be the fastest. While I won't say choosing random ways to go is the best way to do it, it sure looks awesome!](https://repl.it/talk/share/Pathfinder-I/7275) @IEATPYTHON and @Pixelator [Calculators are not uncommon on repl.it talk, however this one succeeds in one that can calculate algebra, easier said then done! But these guys were able to tackle this challenge!](https://repl.it/talk/share/Integer-and-Algebra-calculator/7300) @Fhillis [This weeks platformer comes in the form of a challenging, yet addictive, sensitive one! While it takes practice you really can have a lot of fun with this!](https://repl.it/talk/share/Plat/7350)
2
posted to Announcements by 21natzil (625) 8 months ago
15
Weekly Repl Highlight!
Hello! Welcome to a new series of posts from the repl talk moderation team. We're seeing what awesome projects you guys are making, and decided that each week we would highlight some of our favorite. We had a lot of great submissions, however there can only be one winner. With that said, we do have some honorable mentions. @SingularityV3 [made a great pong game, and is super fun to play with friends!](https://repl.it/talk/share/Pong-HTML/6264) @CSharpIsGud [Made a more practical program, but impressive none the less. He made an HTML parser in C#, and it works great!](https://repl.it/talk/share/Simple-html-reader/6275) @theangryepicbanana [Decided to blow us away with his great editor, now we're just waiting for him to hook it up with the actual language!](https://repl.it/talk/share/Talk-programming-language-Ace-editor-mode/6345) @WiNDfaLLx [Anyone who says you can't be a programmer and an artist is wrong. Along with Wind's great program, they also include amazing pieces of art.](https://repl.it/talk/share/DRAW-with-python-turtle/6407) @derulan [also made their own language this week, but with a twist. If you like the syntax of brackets and the python language, "Rosey" was made for you.](https://repl.it/talk/share/Rosy-Lightweight-Brackets-and-Semicolons-for-Python/6473) @tiki720 Made our second game with week. A multiplayer tank battle, which ends up being tons of fun for the people playing it! With the honorable mentions said and done, the winner is... @tiki720! Funnily enough, tiki made 2 projects that caught our eye. This one was a [cannon simulator](https://repl.it/talk/share/Shooting-Canon/6443), and has great physics that make the project run smoothly. Once again, thank you everyone for your submissions, and we'll select a new project next week!
5
posted to Announcements by 21natzil (625) 9 months ago
10
Weekly Repls #16
Happy new year! It's been a great year everyone, with some awesome repls. Thankfully, this week has been bountiful when it comes to awesome repls. So whip out the sparkling apple cider, and celebrate 2019 with us thanks to these awesome replitors! @DrankArizonaIce [What happens if you combine anime with javascript? WeebScript, javascript with weeb syntax!](https://repl.it/talk/share/WEEBSCRIPT-A-stupid-superset-of-javascript/9629) @21natzil [Don't mean to toot my own horn, but here we go. With this project, you can now import python repls!](https://repl.it/talk/share/Import-other-repls/9628) @Badvillain01 [Created a sweet website, that allows you to modify images to your heart's content!](https://repl.it/talk/share/Image-Editor/9627) @jajoosam [URL shorteners are super useful, why not make your own? This tutorial will help you do exactly that!](https://repl.it/talk/learn/Build-your-very-own-URL-shortener/9611) @jajoosam [This person is back again! Just in time for the holiday season. Add a santa hat to any photo, automagicly!](https://repl.it/talk/share/Santafy-your-images/9619) @theangryepicbanana [The rimp project continues on! This time it's for ruby, and possibly more soon to come.](https://repl.it/talk/share/Import-a-Ruby-repl-in-your-repl/9630) @minermaniac447 [We've had many games inside terminal as of now, but here's a new one. A terminal tetris, made in python!](https://repl.it/talk/share/Pytris/9626) @laksh5 [Brings a fresh new take too snake. Now there are other enemies, trying to attack you while you get food!](https://repl.it/talk/share/Square-Game-Super-Fun-better-than-it-sounds-have-a-look/9632)
2
posted to Announcements by 21natzil (625) 6 months ago
13
Weekly Repls #7
I've gotta say, this week is probably one of the most awesome weeks we've had in a while. So much amazing content was created and I'm so exited I get to share it with you! @Case_Buttitta [shows us that great programs don't need to be complex. This is a funny joke, and got me the first time I tried it] (https://repl.it/talk/share/Internet-Boomerang/7902) @Stanlyhalo [A really sweet proof-of-concept real time editor program. Works really quite well, can't wait to see what they do with this next!](https://repl.it/talk/share/Real-Time-Editor-30/7915) @niorg2606 [This program is really cool, and serves a practical, and just awesome use! Anyone who plays "osu!" needs to check this out!](https://repl.it/talk/share/osusynopsis-a-program-that-analyzes-osubeatmaps/7914) @theangryepicbanana [made a sweet connect-4 game playable entirely in your terminal using Repl Run](https://repl.it/talk/share/Connect-4-in-the-console-with-color-and-animations/7949) @pyelias [Just completely stunned us with this amazing terminal game. If you've ever played cookie clicker, get ready to play it... in the terminal!](https://repl.it/talk/share/Cookie-Clicker-Terminal-Edition/8013) As a side note, the last repl listed was the one that won the code jam. Have a great week everyone!
3
posted to Announcements by 21natzil (625) 8 months ago
16
Weekly Repl Highlight #2
Welcome back to our weekly repl highlights! This week we had a ton of amazing projects. At the start of the week, we received a great tutorial. At first, we weren't completely sure if we would include tutorials in the list, but after getting a second, amazing one, we just *had* too. Now, with our honorable mentions. @Babbel [This is a great turtle project, which if you increase the speed and wait, great art is formed!](https://repl.it/talk/share/2D-Particle-Painter/6528) @ericqweinstein [This tutorial is fantastic, and we're so glad this person decided to share it! If only they posted this *before* our make a language code jam :D](https://repl.it/talk/announcements/LISP-Tutorial-Write-a-Language-with-JavaScript/6566) @MikeShi42 [Made an AMAZING artificial intelligence tutorial, because who doesn't want to raise a machine?](https://repl.it/talk/announcements/From-Scratch-AI-Balancing-Act-in-50-Lines-of-Python/6586) @Joshua18 [A while back, a "cattle trade" game was made, which ended up being a hit. This appears to be it's successor, and it really is fun!](https://repl.it/talk/share/Oil-trading-stimulation/6687) @DJWang [This is our second turtle project, but it doesn't feel like it! It's a great game, play it with all your friends!](https://repl.it/talk/share/Eating-machine-2-Players/6767) @SagaciousPan [Text Adventures are always fun, and this is no exception! My only complaint is that it isn't longer :P](https://repl.it/talk/share/Text_Adventure_Version_02/6769) Finally, the winner is..... @Battlesquid [They created this amazing game, jump of walls, and mess around. Once multiplayer is added, it will be a blast!](https://repl.it/talk/share/BOOST/6597) Thank you to everyone that's on this list, and really everyone that posts their repls. It's so much fun looking at everyone's projects. Keep posting your awesome repls, and I'll see you all next week!
0
posted to Announcements by 21natzil (625) 9 months ago
7
Weekly Repls #23
Hey everyone! Long time no see, I hope you guys are having a great week, and those in the U.S., I hope you enjoyed the long weekend. We have a bunch of new things, including a new[ github organization for the repl.it discord!](https://github.com/repl-it-discord). Now, let's see what people have been up too! @evanzimmerman [Made a super sweet gaming, only using turtle! The game gets harder as you score more points, waddle safely!](https://repl.it/talk/share/Python-Turtle-Game/10781) @PYer [Shares their awesome sci-fi text adventure, which has lost of replay value, as it changes every time!](https://repl.it/talk/share/Aliens-Adventure-Game/10813) @FellowHashbrown [Teaches us how to make our own parsers! It's not as easy as you'd think, and this tutorial really breaks it down!](https://repl.it/talk/learn/Python-Discrete-Math-Logic-Parser/10844) @thejerrytan [Would you like to learn how to make complex data structures, like a Balanced Binary Search Tree in python? Check out this tutorial!](https://repl.it/talk/learn/Learn-how-to-implement-advanced-data-structures-in-Python/10897)
3
posted to Announcements by 21natzil (625) 4 months ago
15
Weekly Highlights #3
We have some great repls for you guys! From large tutorials to adventure games, let's get right into it! @ChillPill [This is a HUGE text adventure game! With so much to do, you could be playing this for a while. Explore! Pro tip: type "Help" for a list of commands.](https://repl.it/talk/share/Console-Adventure-Game-thing/6882 ) @Lamby777 [brings us a great twist on games such as Cookie Clicker. Introducing, Lamb Clicker! This game is a ton of fun to play, and would highly recommend you give it a try.](https://repl.it/talk/share/Sheep-Clicker/7001) @uint9000_t [Creates a bitmap from an image. Really cool to watch and creative. Good Job!](https://repl.it/talk/share/Turtle-Image-Drawing/7016) @ericqweinstein [Eric is back at it again, with a great new tutorial!](https://repl.it/talk/learn/Cave-Commander/7029) @jtupa [Speaking of tutorials, someone decided to share with us their website, containing a large flask tutorial! I'm personally a huge fan of Flask, and felt this deserved a shout-out](https://repl.it/talk/learn/Mega-Flask-Tutorial-from-Miguel-Grinberg/7056) And the winner is... @426729 ! [We have our platformer / winner of the week! This one comes in the form of a challenging, but still awesome, pixely one. One of my favorite things about it is the fact that you can load levels and make your own! Nice job!]( https://repl.it/talk/share/Blocky-3D-Platformer-Jumping-game-Make-your-own-levels-too/6997) Have a great week everyone, and keep repling!
0
posted to Announcements by 21natzil (625) 9 months ago