0

How is my game?!

https://code.sololearn.com/cakwSFOxiC87/?ref=app

11/8/2019 12:39:26 PM

hadi mohamadi

3 Answers

New Answer

+2

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

+3

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: https://code.sololearn.com/cBsox0fB0k4Q/?ref=app

0

Aymane Boukrouh [Inactive] tnx a lot my bro