Write a Python program to generate a 346 3D array whose each element is *.

  • Last updated: September 3, 2024 By Sunil Shaw

array_3d = [[[ '*' for k in range(6)] for j in range(4)] for i in range(3)]

# Print the 3D array
for layer in array_3d:
    for row in layer:
        print(row)
    print()  # Add an empty line after each layer for readability

By using Numpy Library

import numpy as np

# Create a 3D numpy array with dimensions 3x4x6, filled with '*'
array_3d = np.full((3, 4, 6), '*')

# Print the 3D array
print(array_3d)


Sunil Shaw

Sunil Shaw

  • Youtube
  • Instagram
  • Twitter
  • Facebook
About Author

I am a Web Developer, Love to write code and explain in brief. I Worked on several projects and completed in no time.

Popular Language Tutorials

If You want to build your own site Contact Us