Share your repls and programming experiences

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

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 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..

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
                    translation = translation + change
               translation = translation + letter```

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

Keep coding!
cheers :) 
Foster_Bryant (89)

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

JeswinSunsi (31)

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 (31)

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

AdCharity (1325)

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

JeswinSunsi (31)

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

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

You know, it would be a good idea to add comments (like I do in my programs) and maybe put the whole thing in a function, so that it can be run at intervals if required (or you could add a while loop at the start)

But yeah, that's a real cool program

  • from a fellow py3 coder
JeswinSunsi (31)

Forgive the six month older me xD

JeswinSunsi (31)

Agreed with putting the script inside a functions but comments would be overkill and unnecessary. Replace, Lower, Sentence, New_Sentence are all pretty readable.


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.

ChristianTS (1)

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

Foster_Bryant (89)

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)