Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Duplicated printing of the same line #5890

Open
fraioo opened this issue Nov 29, 2020 · 0 comments
Open

Duplicated printing of the same line #5890

fraioo opened this issue Nov 29, 2020 · 0 comments

Comments

@fraioo
Copy link

fraioo commented Nov 29, 2020

The following code ran in 2 different notebooks gives two different results. One of them is duplicating the printing command as you can see (in the screenshots attached)
Captura de ecrã 2020-11-29, às 21 59 34
Captura de ecrã 2020-11-29, às 21 59 53

and the other one is perfectly fine. And yes, I've restarted the kernel and cleaned all outputs before running both. Can you help please? I've spent tons of time around this and cannot figure out what's wrong ...

def user_choice():

choice ='WRONG'
within_range = False

while choice.isdigit() == False or within_range == False:
    
    choice = input("Please enter a number (0-10): ")
    
    if choice.isdigit() == False:
        print("Sorry that is not a digit!")
        
    if choice.isdigit() == True:
        if int(choice) in range(0,11):
            within_range = True
        else:
            print("Sorry, that number is not between 0-10.")
            within_range = False

return int(choice)`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant