Python ' loops for iteration and question.

Asked 2 years ago, Updated 2 years ago, 19 views

I want to print it out in a repetitive form without entering it one by one like it's on a comment As soon as I spin the repeat, is there a way for each text to be read like that?

Thank you!

python

2022-09-22 18:43

1 Answers

You can use the for statement, but I did it in one line with list compression and join.

I'm not sure what the labels in the back mean.

for i in range(10):
    print(' '.join('(%s %s)'%(batch[i, j], reverse_dict[batch[i, j]) for j in range(4)),
          '->'< labels[i, 0], reverse_dict[labels[i, 0]])

PS. Please put the code as a code block of markdown grammar rather than capture.


2022-09-22 18:43

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.