---
title: "PadRight"
language: "en"
type: "Symbol"
summary: "PadRight[list, n] makes a list of length n by padding list with zeros on the right. PadRight[list, n, x] pads by repeating the element x. PadRight[list, n, {x1, x2, ...}] pads by cyclically repeating the elements xi. PadRight[list, n, padding, m] leaves a margin of m elements of padding on the left. PadRight[list, {n1, n2, ...}] makes a nested list with length ni at level i. PadRight[list] pads a ragged array list with zeros to make it full."
keywords: 
- padding
canonical_url: "https://reference.wolfram.com/language/ref/PadRight.html"
source: "Wolfram Language Documentation"
related_guides: 
  - 
    title: "Rearranging & Restructuring Lists"
    link: "https://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.en.md"
  - 
    title: "Constructing Matrices"
    link: "https://reference.wolfram.com/language/guide/ConstructingMatrices.en.md"
related_functions: 
  - 
    title: "PadLeft"
    link: "https://reference.wolfram.com/language/ref/PadLeft.en.md"
  - 
    title: "ArrayPad"
    link: "https://reference.wolfram.com/language/ref/ArrayPad.en.md"
  - 
    title: "Join"
    link: "https://reference.wolfram.com/language/ref/Join.en.md"
  - 
    title: "Partition"
    link: "https://reference.wolfram.com/language/ref/Partition.en.md"
  - 
    title: "ArrayReshape"
    link: "https://reference.wolfram.com/language/ref/ArrayReshape.en.md"
  - 
    title: "CenterArray"
    link: "https://reference.wolfram.com/language/ref/CenterArray.en.md"
  - 
    title: "ListCorrelate"
    link: "https://reference.wolfram.com/language/ref/ListCorrelate.en.md"
  - 
    title: "Riffle"
    link: "https://reference.wolfram.com/language/ref/Riffle.en.md"
  - 
    title: "RotateRight"
    link: "https://reference.wolfram.com/language/ref/RotateRight.en.md"
  - 
    title: "StringPadRight"
    link: "https://reference.wolfram.com/language/ref/StringPadRight.en.md"
related_tutorials: 
  - 
    title: "Rearranging Lists"
    link: "https://reference.wolfram.com/language/tutorial/Lists.en.md#1331"
  - 
    title: "Nested Lists"
    link: "https://reference.wolfram.com/language/tutorial/ManipulatingLists.en.md#15721"
  - 
    title: "Partitioning and Padding Lists"
    link: "https://reference.wolfram.com/language/tutorial/ManipulatingLists.en.md#14460"
---
# PadRight

PadRight[list, n] makes a list of length n by padding list with zeros on the right. 

PadRight[list, n, x] pads by repeating the element x. 

PadRight[list, n, {x1, x2, …}] pads by cyclically repeating the elements xi. 

PadRight[list, n, padding, m] leaves a margin of m elements of padding on the left. 

PadRight[list, {n1, n2, …}] makes a nested list with length ni at level i. 

PadRight[list] pads a ragged array list with zeros to make it full.

## Details

* ``PadRight[list, n, …]`` always returns a list of length ``n``, except in some special cases where ``padding`` is ``{}``.

* With padding ``{x1, x2, …, xs}``, cyclic repetitions of the ``xi`` are effectively laid down and then the list is superimposed on top of them, with the first element of the list lying on an occurrence of ``x1``. »

* A margin of ``Round[(n - Length[list]) / 2]`` effectively centers ``list``.

* ``PadRight[list, n, list]`` effectively treats ``list`` as cyclic.

* ``PadRight[list, n, {xlist}]`` can be used to repeat an individual element that is itself a list.

* ``PadRight[{}, n, {x1, x2, …}]`` repeats the sequence of ``xi`` as many times as fit in a list of length ``n``.

* ``PadRight[list, {n1, n2, …}]`` creates a full array with dimensions ``{n1, n2, …}`` even if ``list`` is ragged. »

* ``PadRight[list, Automatic, x]`` pads with ``x`` to make a full array.

* Negative ``ni`` specify to pad on the left.

* ``PadRight[list, {n1, n2}, {{x11, x12, …}, {x21, …}, …}]`` pads by repeating the block of ``xij``.

* ``PadRight[list, {n1, n2, …}, list]`` effectively treats ``list`` as cyclic in every dimension.

* ``PadRight[list, {n1, n2, …}, padding, {m1, m2, …}]`` uses margin ``mi`` at level ``i``.

* The object ``list`` need not have head ``List``.

* ``PadRight`` can be used on ``SparseArray`` objects.

---

## Examples (14)

### Basic Examples (6)

Pad with ``0`` to make the list be of length 10:

```wl
In[1]:= PadRight[{a, b, c}, 10]

Out[1]= {a, b, c, 0, 0, 0, 0, 0, 0, 0}
```

---

Pad with ``x`` :

```wl
In[1]:= PadRight[{a, b, c}, 10, x]

Out[1]= {a, b, c, x, x, x, x, x, x, x}
```

---

Pad by repeating ``{x, y, z}`` :

```wl
In[1]:= PadRight[{a, b, c}, 10, {x, y, z}]

Out[1]= {a, b, c, x, y, z, x, y, z, x}
```

---

Leave margin ``2`` on the left:

```wl
In[1]:= PadRight[{a, b, c}, 10, x, 2]

Out[1]= {x, x, a, b, c, x, x, x, x, x}
```

---

Pad to make a 3×4 array:

```wl
In[1]:= PadRight[{{a, b}, {c}}, {3, 4}]//TableForm

Out[1]//TableForm=
|   |   |   |   |
| :- | :- | :- | :- |
| a | b | 0 | 0 |
| c | 0 | 0 | 0 |
| 0 | 0 | 0 | 0 |
```

---

Pad to make a full array:

```wl
In[1]:= PadRight[{{a, b, c}, {d, e}, {f}}]//TableForm

Out[1]//TableForm=
|   |   |   |
| :- | :- | :- |
| a | b | c |
| d | e | 0 |
| f | 0 | 0 |
```

### Scope (3)

Negative length specifications pad on the left:

```wl
In[1]:= PadRight[{a, b, c}, -10]

Out[1]= {0, 0, 0, 0, 0, 0, 0, a, b, c}
```

---

Lay down repetitions of the padding, then superimpose the original array:

```wl
In[1]:= PadRight[{{aa, bb}, {cc}}, {4, 4}, {{x, y}, {z}}]//TableForm

Out[1]//TableForm=
|    |    |   |   |
| :- | :- | :- | :- |
| aa | bb | x | y |
| cc | z  | z | z |
| x  | y  | x | y |
| z  | z  | z | z |
```

---

Use different margins for rows and columns:

```wl
In[1]:= PadRight[{{aa, bb}, {cc}}, {5, 5}, {{x, y}, {z}}, {1, 2}]//TableForm

Out[1]//TableForm=
|   |   |    |    |   |
| :- | :- | :- | :- | :- |
| z | z | z  | z  | z |
| x | y | aa | bb | x |
| z | z | cc | z  | z |
| x | y | x  | y  | x |
| z | z | z  | z  | z |
```

### Generalizations & Extensions (1)

Use a head other than ``List`` :

```wl
In[1]:= PadRight[f[a, b, c], 8, x]

Out[1]= f[a, b, c, x, x, x, x, x]
```

### Applications (2)

Put a ``1`` at the center of a list of ``0``s:

```wl
In[1]:= PadRight[{1}, 19, 0, 9]

Out[1]= {0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0}
```

---

Lay out an array of tiles:

```wl
In[1]:= ArrayPlot[PadRight[{{}}, {15, 15}, {{1, 0, 1}, {0, 1, 1}, {1, 0, 0}}], Mesh -> True]

Out[1]= [image]
```

### Properties & Relations (1)

``PadLeft[list, n]`` and ``PadRight[list, n]`` pad to make a list of length ``n`` :

```wl
In[1]:= PadLeft[{1, 2, 3}, 5]

Out[1]= {0, 0, 1, 2, 3}

In[2]:= PadRight[{1, 2, 3}, 5]

Out[2]= {1, 2, 3, 0, 0}
```

``ArrayPad[list, n]`` pads with ``n`` additional elements on each side:

```wl
In[3]:= ArrayPad[{1, 2, 3}, 5]

Out[3]= {0, 0, 0, 0, 0, 1, 2, 3, 0, 0, 0, 0, 0}
```

### Possible Issues (1)

Pad with an element that is itself a list:

```wl
In[1]:= PadRight[{a, b, c}, 7, {{u, v}}]

Out[1]= {a, b, c, {u, v}, {u, v}, {u, v}, {u, v}}

In[2]:= PadRight[{a, b, c}, 7, {u, v}]

Out[2]= {a, b, c, v, u, v, u}
```

## See Also

* [`PadLeft`](https://reference.wolfram.com/language/ref/PadLeft.en.md)
* [`ArrayPad`](https://reference.wolfram.com/language/ref/ArrayPad.en.md)
* [`Join`](https://reference.wolfram.com/language/ref/Join.en.md)
* [`Partition`](https://reference.wolfram.com/language/ref/Partition.en.md)
* [`ArrayReshape`](https://reference.wolfram.com/language/ref/ArrayReshape.en.md)
* [`CenterArray`](https://reference.wolfram.com/language/ref/CenterArray.en.md)
* [`ListCorrelate`](https://reference.wolfram.com/language/ref/ListCorrelate.en.md)
* [`Riffle`](https://reference.wolfram.com/language/ref/Riffle.en.md)
* [`RotateRight`](https://reference.wolfram.com/language/ref/RotateRight.en.md)
* [`StringPadRight`](https://reference.wolfram.com/language/ref/StringPadRight.en.md)

## Tech Notes

* [Rearranging Lists](https://reference.wolfram.com/language/tutorial/Lists.en.md#1331)
* [Nested Lists](https://reference.wolfram.com/language/tutorial/ManipulatingLists.en.md#15721)
* [Partitioning and Padding Lists](https://reference.wolfram.com/language/tutorial/ManipulatingLists.en.md#14460)

## Related Guides

* [Rearranging & Restructuring Lists](https://reference.wolfram.com/language/guide/RearrangingAndRestructuringLists.en.md)
* [Constructing Matrices](https://reference.wolfram.com/language/guide/ConstructingMatrices.en.md)

## History

* Introduced in 1999 (4.0) \| Updated in 2003 (5.0) ▪ [2007 (6.0)](https://reference.wolfram.com/language/guide/SummaryOfNewFeaturesIn60.en.md)