I wanted to multiply a string and store them into a variable, heres an example of what I wanna do but in Python:
a = "A" * 200
If you just need to repeat the string n times you should use string.rep
string.rep (s, n [, sep])
Returns a string that is the concatenation of n copies of the string s separated by the string sep. The default value for sep is the empty string (that is, no separator). Returns the empty string if n is not positive.
(Note that it is very easy to exhaust the memory of your machine with a single call to this function.)
If you want to use the multiplication syntax you can implement the __mult metamethod in the string metatable
getmetatable("a").__mult = string.rep
This will change Lua's behaviour though. Lua will implicity convert "1" * "4" to 1 * 4 which resolves to 4. After our change it will result in "1111"
This might cause problems later. Also this affects all strings so you probably change code of others who did not intend to do it like this in your common code base.
So I'd personally recommend to stick with string.rep whenever you need to repeat a string.
pete & repete were in a boat... Notice the intentional misspelling of repeat, as that's a keyword in Lua. You use concatenation, with a container.
#! /usr/bin/env lua
local pete, repete, boat = 'a', 20, ''
for a = 1, repete do boat = boat ..pete end
print( boat )
aaaaaaaaaaaaaaaaaaaa
local C= '' ; while #C < 20 do C= C ..'a' end