arr1 = []
arr2 = []
arr3 = []
for i in arr1:
for j in i:
if j==0:
print('', end='')
else:
print('*', end='')
print()
for i in arr2:
for j in i:
if j==0:
print('', end='')
else:
print('*', end='')
print()
for i in arr3:
for j in i:
if j==0:
print('', end='')
else:
print('*', end='')
print()
When I print out arr1, arr2, arr3, I want to do the last line and turn it over to the side without opening it, what should I do?
I thought I could do end='\t', but it doesn't work well even if I put it in here and there<
python
Python's zip (*iterables) allows you to tour multiple lists at once.
list1 = [1, 2, 3, 4]
list2 = [100, 120, 30, 300]
list3 = [392, 2, 33, 1]
answer = []
for i, j, k in zip(list1, list2, list3):
answer.append( i + j + k )
If you do not modify the original logic, apply it
arr1 = [[0,1,1], [0,0,1],[0,0,0]]
arr2 = [[1,1,1], [1,0,0], [0,0,0]]
arr3 = [[1,0,1], [1,1,0], [0,0,0]]
for i, j, k in zip(arr1, arr2, arr3):
str1, str2, str3 = '', '', ''
for a,b,c in zip(i,j,k):
if a==0:
str1 += ''
else:
str1 += '*'
if b==0:
str2 += ''
else:
str2 += '*'
if c==0:
str3 += ''
else:
str3 += '*'
print(str1, str2, str3)
I think we can do it like this!
554 rails db:create error: Could not find mysql2-0.5.4 in any of the sources
551 Uncaught (inpromise) Error on Electron: An object could not be cloned
553 Understanding How to Configure Google API Key
556 PHP ssh2_scp_send fails to send files as intended
764 When building Fast API+Uvicorn environment with PyInstaller, console=False results in an error
© 2024 OneMinuteCode. All rights reserved.