12 Answers

New Answer""" Oma Falk you need to specify dtype="object" to your string array """ import numpy as np a = np.array([list("word")],dtype='object').T # or dtype='O' print(a) b = np.array([[5]]) print(b) print(a.dot(b)) [print(*w) for w in a.dot(b)] print(*list(np.concatenate(a.dot(b)).flat))

Oma Falk No, it is not defined, don't let Python make you believe that! π numpy is not Python string repetition. numpy *matrix operations* are math.

import numpy as np n = 5 arr0 = np.array(list('word')) # 1. repeat # 2. reshape arr = np.repeat(arr0, n).reshape(len(arr0), n) print(arr)

What is the expected output? A matrix with "word" as columns? As matrix operations are only the defined for numbers, I wouldn't expect it to work with characters. I probably would either repeat and concatenate the matrix or try to use integers instead of characters.

I expected wwwww ooooo rrrrr ddddd Multiplication between integers and chars is defined. So why not matrix multiplication π€

When I specified the out argument (as an array of string) inside dot method, it raised an error that says "ValueError: dot not available for this type". So I looked for other numpy methods that could work with strings. np.repeat() method will repeat elements inside numpy array, based on the second argument. I tried four methods with different output (as I don't know your exact desired output yet). The last two require some list comprehension though, and is somewhat manually multiplied. https://code.sololearn.com/cAZ9vkJAyt87/?ref=app

Maninder singh your reply is off the topic. Please start a new Q&A post to ask your own questions. I do have a quick answer for you, nonetheless: You misspelled "length".

Function add() If (arguments.lenght==0){ console.log("no argument found"); }; Else{ console.log(arguments.lenght); }add(5,6) Hi guys in this code above there is an error in the line 2 but I did not found I am trying to prove that if arguments.lenght==0 Output no arguments found Else Output argument.length Please help me