how to use timeit in python 3
import timeit
import_module = "import random"
testcode = '''
def test():
return random.randint(10, 100)
'''
print(timeit.repeat(stmt=testcode, setup=import_module))
how to use timeit in python 3
import timeit
import_module = "import random"
testcode = '''
def test():
return random.randint(10, 100)
'''
print(timeit.repeat(stmt=testcode, setup=import_module))
in python how to end the code after 10 input
incorrect = 0
max_tries = 3
choices = ['red', 'green', 'yellow']
while incorrect < max_tries:
user_input = raw_input()
if user_input not in choices:
incorrect += 1
else:
rest_of_the_code(user_input)
incorrect = 0
if incorrect == max_tries:
sys.exit(1)
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us