0
Strings in arrays
Does anyone know how to print the first letter of each string in an array?
3 Respostas
+ 1
This task is language dependent, so specify relevant language in the thread's tags above ☝
+ 1
in almost languages arrays (lists in python built-ins) each elements is accessible trough square brackets notation...
as string are almost character array, you could also access each char through square brackets...
so you need a loop to iterate over string array, and output only the character at index 0 of each string:
str_item[0]
Fazz Reaper edit:
with i as the array index:
str_array[i][0]
0
In python
import numpy as np
name = np.array(["sinam", "tashi", "somi"])
for i in name:
print(i[0], end="")