How is my game?! | SoloLearn: Learn to code for FREE!


How is my game?!

11/8/2019 12:39:26 PM

hadi mohamadi

3 Answers

New Answer


hadi mohamadi I just edited my answer and added the code. No problem!


Good, but you can make it better. 1. What is the use of b=2 ? If you're not using it inside the loop, then it's just a waste of memory. Since you're using break statement to stop your loop, it is better to use: while True: # your code here 2. Instead of having to convert 'a' to int everytime you want to use it, simply take it as an input from the first place: a = int(input('Enter a number between 1 and 100: ')) 3. The 3rd elif statement is usless, you're verifying a condition that doesn't matter. If a is not num, and if it is superior than n, then what do you think can it be ? It can only be smaller than n, so checking that condition is a waste of time (small, but can matter in more complex programs), try to use else at the end instead of elif. 4. This is just a new feature, but the walrus expression is definetly useful in this code, if you don't know what that is, check "Walrus python 3.8" in google. Here is a modified version of your code:


Aymane Boukrouh [Inactive] tnx a lot my bro