About 1,850,000 results
Open links in new tab
  1. python - Print a word diagonally? - Stack Overflow

    Oct 9, 2016 · I'm new to python, so I'm trying to understand how to print a word diagonally (either right to left or vice versa). So far, I've been trying to write it all under one function by defining the function.

  2. python - How to create a function to print a word going in …

    Jan 11, 2021 · I'm looking to create a function that takes a word and print it in a specified direction: when n = 0, print vertically, when n = 1 print diagonally. def word_direction(text, direction=n): print(word)

  3. Python Printing Diagonal Pattern - Stack Overflow

    Nov 12, 2021 · print(" ", end = "") print(i) print(" ") You can prepare a string of spaces and print a substring of it on each line starting at the positon if the current index: print(spaces[i:],i) Probably better to use sep='' for extra space added in every line.

  4. How to find the coordinates (diagonally)? - Reddit

    Sep 28, 2019 · One last thing I would need to do is how to basically find the coordinates of the first letter of a word diagonally. So basically this is the section for the diagonals. for q in range(min(p, column_length-1), max(0, p-row_length+1)-1, -1)] for p in range(column_length+row_length-1)] for q in range(max(p-column_length+1,0), min(p+1, …

  5. Print diagonals of 2D listPython | GeeksforGeeks

    Jan 31, 2025 · The task of printing diagonals of a 2D list in Python involves extracting specific elements from a matrix that lie along its diagonals. There are two main diagonals in a square matrix: the left-to-right diagonal and the right-to-left diagonal.

  6. Assignment Write a Python program that takes a word as input

    Assignment: Write a Python program that takes a word as input from the user and prints it on the reverse diagonal of a grid, from the top-right to the bottom-left. All other cells should be filled with hyphens (-). The size of the grid should be determined by a second input provided by the user.

  7. Finding the coordinates of a diagonal word in a matrix (python). - Reddit

    Sep 28, 2019 · Finding all the diagonals and putting them into an artificial row seems like an unnecessary step when you could iterate through the matrix to find the first letter of the word you're looking for and then search diagonally for the next letter in the sequence.

  8. In Python word search, searching diagonally, printing result of

    Jan 30, 2015 · If I find the word, I must print in what row and what column (the coordinates) the word starts and the word ends. I've only been learning Python 2 weeks so I'm confused, how would I search for a word diagonally and get the starting point and ending point of a word?

  9. numpy.diag() in Python - GeeksforGeeks

    Mar 9, 2022 · numpy.diag(a, k=0) : Extracts and construct a diagonal array Parameters : a : array_like k : [int, optional, 0 by default] Diagonal we require; k>0 means diagonal above main diagonal or vice versa. Returns : ndarray

  10. Drawing a diagonal line of one character using nested while loops

    May 5, 2016 · Basically, to make a diagonal line without the fill, is to print a space character (with end="") for each row, except for the final character in each row. Here's the code I used for the diag, ask if you have questions. for n in range(1,size+1): #where n is row number. for i in range(n-1): print(" ", end="") print (char) The result:

  11. Some results have been removed
Refresh