+ 2
how to print array of strings
3 odpowiedzi
+ 2
if we set ( sports = ['football','basketball','tennis','swimming'] ) we can simply print it by typing : print(sports)
+ 2
To print the strings one by one:
array = ["Welcome", "to", "my", "kingdom"]
# This array is simply an example. ANY array would do!
for i in array:
print(i)
# This code prints each item (in this case, string) in the array one by one.
The output:
Welcome
to
my
kingdom
If you just want to print a specific string, you can just call its position:
print(array[3])
The output would be:
kingdom
0
can we access one by one