Python Tutorial on Printing a list without the quotation marks [" "]
Python Tutorial on Printing a list without the quotation marks " "
Let me explain myself a little further.
Since when you print a list, this is what it should print out.
It literally printed out the list. How do you print out Python is awesome without doing print("Python is awesome") and you need to create a list?
This is what tutorials are for >:).
Only need to import sys
Create a list
You have to create a list of the things you want to print.
In this case, it's Python is awesome.
Actual logic/code Step 1
Now we got everything set up, time for the logic!
In order to print everything, we need to print each and individual index of the list like:
But that's wayyyyyy to slow. And coding is about efficient code. The less the better (but has to be the same output).
Now you think about it, we need to use a
for loop. But how many times? We can't just count how many indexes there are, so we do this cool function,
len(sentence) will calculate how many indexes are in the list.
So first steps is:
What is in the for loop? Before that, we have to assign a variable a value because in the for loop, we should keep adding on to the variable the number of how many indexes. (If you are confused, I failed.😞😭) But let's see the actual code.
Now we got that, we need to keep adding on to x:
TADA!🎉. Looks through code. Hold the phony, there is a mistake. If you printed that out, then it will print Python is awesome, each letter will be printed out in a different lin. That's why we imported sys! To have the trusty function
sys.stdout.write(). And it will print everything in just ONE line!
FINAL/TOTAL CODE OF ALL!!
You can see the repl down below, and don't forgot to check my terrible Bio💳! https://bio.xthacker.repl.co/
Until my next...project/tutorial (I haven't been posting projects in a while...😜. I will manage to post one soon. Look at my profile for my animations!) Without further ado, a peace! falls of chair