Skip to content

what is the importance of of the line after break [some_random_character = rand(0, 120)]? #1

@HELLO-NIKHIL

Description

@HELLO-NIKHIL

from random import randrange as rand
from time import sleep

A very beautiful function which will keep printing a string with a random character, until the expected character

is drawn

def print_string(current_string, expected_character):
some_random_character = rand(0, 120)
while True:
print("\r" +current_string + chr(some_random_character), end="")
sleep(0.001) # Comment this line to see the result instantly
if chr(some_random_character) == expected_character:
break
some_random_character = rand(0, 120)

my_string = "Hello World"
current_str = ""

Try to get the matching character for every character in the string. Good Luck!

for letter in my_string:
print_string(current_str, letter)
current_str += letter

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions