Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

Python 

Need help (easy python task)

Hey, I really need some help. Can someone send me a code that asks the user for his/her name and prints out each letter of the name separately?
It's for my python class, I was sick for like 2 weeks straight and now I can't do shit 🤝
"prints out each letter of the name separately?"

What do you mean by this?

And I offer Java/Python services, feel free to contact me on Skype @ Eclips3.HF
(Feb 20, 2016 12:37 PM)Stealth™ Wrote:  "prints out each letter of the name separately?"

What do you mean by this?

And I offer Java/Python services, feel free to contact me on Skype @ Eclips3.HF

I'm not sure but lets say it asks for your name, you type in "Tom" and it prints T, O, M like this [Image: Nb9KrY5.png] but with using a cycle and not typing out "print" all the time. I'm bad at english, i dont know if you got me 😵
I'm not on my computer right now, but you'll need a loop like this.

PHP Code

<?php 
i
=0
while i < len(text):
    print 
text[i]
    
i += 1 
[Image: npafFhp.gif]
(Feb 20, 2016 12:45 PM)Gameh3x Wrote:  I'm not sure but lets say it asks for your name, you type in "Tom" and it prints T, O, M like this [Image: Nb9KrY5.png] but with using a cycle and not typing out "print" all the time. I'm bad at english, i dont know if you got me 😵

I'm guessing you mean that it prints each letter on a new line?

You can just tack on '\n' after each letter when printing in a for-loop.
PHP Code

<?php 
print [x for x in "b3mb4m"] 


?? ..
Code
name = str(input("Name :"))

for elt in name :
     print(elt)

Can also be done in 2 lines but who cares...

This is 100% what you need, easiest and cleanest way of doing it.
(Feb 20, 2016 01:57 PM)SIM-1866423 Wrote:  
PHP Code

<?php 
print [x for x in "b3mb4m"] 


?? ..

haha not really. That's just going to print out a list. The easiest you can do is:
PHP Code

<?php 
print('\n'.join(list("YourNamehere"))) 

That'll at least work in python 2/3


(Feb 20, 2016 12:50 PM)Retribute Wrote:  I'm not on my computer right now, but you'll need a loop like this.

PHP Code

<?php 
i
=0
while i < len(text):
    print 
text[i]
    
i += 1 

Why have a counter? Even if you wanted to use a loop, you can just do:
PHP Code

<?php 
for letter in "YourNameHere":
    print(
letter) 
SRPP Discord Server

I am a professional network/cloud security architect.
My Old Tutorials
For the sake of 2 lines of code you may as well just tried to do it yourself, anyone that gave you the answer in this thread didn't actually help you.
I can help you with this, I am a Computer Engineering student.. Just PM me if you want...
[Image: 4qiWbE.gif]
For completion's sake, there's a one-line way of writing this:

Code
[print(letter) for letter in input("Username: ")]

A breakdown of what the code is doing:
This process is called list comprehension as we iterate through a list(Your username is a list of characters/letters) - each of these is printed one after another.
Still searching for code pm me


Possibly Related Threads...
Thread / Author Replies Views Last Post
[Python] by Bass_ReevesAug 20, 2023 01:44 AM 9 632 Aug 20, 2023 01:44 AM
Last Post: Lucky4L
[Python] by Too FarJul 14, 2022 09:00 AM 2 159 Jul 14, 2022 09:00 AM
Last Post: Too Far
[Python] by blackcoder00Mar 6, 2019 08:33 AM 7 505 Mar 6, 2019 08:33 AM
Last Post: datguy.dev