Skip to content
Sign upLog in
← Back to Community

How do I make the letters parallel to each other?

Profile icon
CosmicWonderhoo

I would like to make the letters parallel to each other with delay and without having the word print out all at once. Please my fellow python programmers help meh.

Answered by Coder100 [earned 5 cycles]
View Answer
Voters
Profile icon
CosmicWonderhoo
Comments
hotnewtop
Profile icon
Coder100

Hey, it appears you are trying to use a slowprint?

import time def typewriter(text, delay=0.1): for letter in text: print(letter, end='', flush=True) time.sleep(delay) print() typewriter("I'm being typed at a rate of 0.1 seconds") typewriter("I'm being typed at a rate of 0.05 seconds", 0.05)

The second parameter is optional and is in seconds. It defaults to 0.1.

Profile icon
CosmicWonderhoo

@Coder100
thank you very much I'm very grateful because you solved my issue it was kind of hard for me to figure out at first but since it was just python it took five min. I will make sure to credit you when I finish this.

Profile icon
gibbsfreenergy

@Coder100
Is there a difference between this and typewriter?

Profile icon
Coder100

no

@JosephSanthosh

Profile icon
Coder100

no problem!! :D Happy to help

@CosmicWonderhoo

Profile icon
Coder100

they can be used interchangeably

@JosephSanthosh

Profile icon
SixBeeps

You need to set the end parameter for the print function, something like

print('h', end='') print('i', end='')
Profile icon
CosmicWonderhoo

@SixBeeps
Thank you very much but that code puts the print parallel all out at once, without printing each letter out with delay but it does put the letters parallel though.

I'm very grateful that you replied thank you very much.

Profile icon
SixBeeps

@CosmicWonderhoo
The idea is that you'd add the end parameter to all of your existing print statements in the Repl you provided.

Profile icon
SixBeeps

@CosmicWonderhoo
Actually, check out this repl. This is a more efficient way to do things.

Profile icon
CosmicWonderhoo

@SixBeeps
I appreciate this more efficient thank you very much. this code is simple and informative. Ill make sure to credit you when I finish this. I'm pretty sure a child could understand.

Profile icon
gibbsfreenergy

I know what you are saying! You want the typewriter effect, where the text comes one by one delated, am I right? Here is the typewriter effect, just copy paste it at the top of the main.py file:

import os import random, curses, sys, time from time import sleep st = 0.04 def sp1(str): for letter in str: sys.stdout.write(letter) sys.stdout.flush() time.sleep(0.06) print()

To make it faster change time.speed(0.06) to time.speed(0.04). To make it slower change time.speed(0.06) to time.speed(0.08).

I hope this helps you and have a great day my friend!

Profile icon
CosmicWonderhoo

@JosephSanthosh
thank you very much for your answer this code was easy and simple to understand. I went with the fast one with 0.06 in a different repl.

Profile icon
gibbsfreenergy

That's wonderful good job

@CosmicWonderhoo