How to print patterns in one line in Python 3?

I have this code to print ‘H’ in a pattern using ‘*’: def grid_h(): result_str=”; for row in range(5): for column in range(5): if((column == 0 or column == 4) or (row == 2)): result_str = result_str + ‘*’ else: result_str = result_str + ‘ ‘ result_str = result_str + ‘\n’ return result_str I’m trying… Read More How to print patterns in one line in Python 3?

how can I use fixture to create a mock file of certain size?

I’m doing something like this def test_collection_size(create_fake_file): files = [create_fake_file] size = get_collection_size(files) assert size == 32 create_fake_file fixture should return a mock file of size 32 bytes I did something like this @pytest.fixture def fake_file_content(): # Returns 32 bytes of space return b" " * 32 @pytest.fixture def create_fake_file(fake_file_content): def _create_fake_file(file_path): # Use unittest.mock.mock_open… Read More how can I use fixture to create a mock file of certain size?

Issue retrieving character from a string variable in Pine Script

I’m trying to retrieve the second character from a string variable: string myString = "Hello" string secondChar = myString[1] However, instead of getting "e," the result is "Hello." What am I doing wrong? >Solution : [] in pinescript is called history-referencing operator. It is used to access historical values of a variable. You can convert… Read More Issue retrieving character from a string variable in Pine Script

How to join a sequence of tuples, each with its own sequence?

I have a sequence of tuples where each tuple contains another sequences. To better illustrate the problem, please have a look at the below snippet (Rust Playground): fn main() { let data = [ (vec![1, 2, 3], vec![‘a’]), (vec![4, 5, 6], vec![‘b’, ‘c’]) ]; let res: (Vec<i32>, Vec<char>) = data…? // res = (vec![1, 2,… Read More How to join a sequence of tuples, each with its own sequence?