Share your repls and programming experiences

← Back to all posts
A Cool Python Mini App
JeswinSunsi (28)

Hey!
Here's a small program that I made in Python. The code was inspired from Mike Dane. (He's really good, go check him out too at MikeDane.com) My program allows the user to replace a letter to another specific one in a given sentence..
Please do upvote and check out some of my other cool stuff..
Thenks,
Lona..

Commentshotnewtop
Monitor (3)

It works as intended but I have some comments about your code style (I just mean help so please do not take offence):
1. You have no comments in your code.
2. You have 3 variables defined in global scope.
3. You have code repetition (3 input statements).
4. You do not have a main function.
5. You are using quite nested loop.
6. The following code section can be formatted with less redundant code:

               if letter.isupper():
                    translation = translation + change
               else:
                    translation = translation + change
          else:
               translation = translation + letter```

If you want, you can look at the same program I write differently.

Keep coding!
cheers :) 
Foster_Bryant (96)

@Monitor What is the point of a main function when you can just run the code.

JeswinSunsi (28)

@Monitor
Hey! Thanks for the reply.. Im just a beginner in Python and am learning. I really don't know what global variables are but sure thanks for telling me abt them.
Cheers To You To!

Monitor (3)

@Foster_Bryant Not as it is, but If you want to develop further and may be import this file into some other program, or make small modules part of a big program later etc. then you're gonna realise that you will need it. However, it's a choice of a developer, I think It's a good practice to run the functions inside the main function, some programming language enforce it strictly, Python does not. Still, I think it's a good practice.

JeswinSunsi (28)

@Monitor
Yup totally agree with you. Should def()initely do that next tym.

AdCharity (1113)

Wait isn't there a replace function for a reason?

JeswinSunsi (28)

@AdCharity
Omg I'm so dumb I never even knew replace() existed..
thenks anyway

bossotron13 (65)
Change = input(‘change: ’)
New = input(‘New: ’)
sent = input(‘Sent: ‘)
print(sent.replace(Change, New))
BENJAMINGALLOWA (0)

A nice thing to add would be a loop, using while True or a for loop, just so you don't have to re-run the program for each new sentence.

JeswinSunsi (28)

@BENJAMINGALLOWA
Ya, I do want to add a while loop but im barely getting time. Im 14 and school is killing me. lol. Thenks anyway

ChristianTS (1)

@JeswinSunsi You could have added one and it would have been quicker than typing out that reply.

JeswinSunsi (28)

@ChristianTS
Bruv shut up. I code on my PC and I typed that out in my phone. And im not adding loop now cuz iv moved on to another project. Add a loop if you want, that is, if you even know how to code..

Raedii (0)

It's a very simple program. Be humble, you have a lot more to learn. You said "cool" but really, it's basic.

JeswinSunsi (28)

@Raedii
Yah I don't really care. Its cool for me.

Foster_Bryant (96)

if it would print the same thing if it was upper in that if statement why even have an if statement if either way they would do the same thing? (line 9 to 11)