I want to use tqdm in a loop such as: def __process_each_iteration(self, imputer) -> tuple[int, float, float]: progress_bar= tqdm( range(self.base_imputed_df.shape[1]), desc="Processing...: ", bar_format=( "{l_bar}{bar}| Iteration {n_fmt}/{total_fmt} " "[{elapsed}<{remaining}, {rate_fmt}]" ), ) for col_index in progress_bar: pass progress_bar.close() def fit_transform(self): for idx, imputer in enumerate(range(10)): change, avg_train_metric, avg_val_metric = self.__process_each_iteration(imputer) pass... when I run the above code, it gives me the following output: Iteration 1/9 Processing...: 100%|██████████| Iteration 30/30 [00:09<00:00, 3.26it/s] Processing...: 0%| | Iteration 0/30 [00:00<?, ?it/s]30 columns updated. Average r2_score -> train: 0.9665220914801507, val: 0.7951696912960284 Iteration 2/9 Processing...: 100%|██████████| Iteration 30/30 [00:13<00:00, 2.30it/s] Processing...: 0%| | Iteration 0/30 [00:00<?, ?it/s]19 columns updated. Average r2_score -> train: 0.9849819806147938, val: 0.85501137134333 it prints two progress bars in each iteration I used tqdm as follows: with tqdm(...) as but I had the same problem... Continue reading...