down 'down up 'up head 'head body 'body feet 'feet get the size of the terminal window width shutil get_terminal_size()[ we can' print to the last column on windows without it adding newline automaticallyso reduce the width by one width - def main() print('duckling screensaverby al sweigart' print('press ctrl- to quit ' time sleep( ducklinglanes [none(width /duckling_width while truemain program loop for lanenumducklingobj in enumerate(ducklinglanes) see if we should create duckling in this lane if (ducklingobj =none and random random(<density) place duckling in this lane ducklingobj duckling( ducklinglanes[lanenumducklingobj if ducklingobj !none draw duckling if there is one in this lane print(ducklingobj getnextbodypart()end='' delete the duckling if we've finished drawing it if ducklingobj parttodisplaynext =none ducklinglanes[lanenumnone else draw five spaces since there is no duckling here print(duckling_widthend='' print(print newline sys stdout flush(make sure text appears on the screen time sleep(pause class duckling def __init__(self) """create new duckling with random body features "" self direction random choice([leftright] self body random choice([chubbyvery_chubby] self mouth random choice([openclosed] self wing random choice([outupdown] if self body =chubby chubby ducklings can only have beady eyes self eyes beady project #