# Println and tuple format query

**URL:** <https://discourse.julialang.org/t/println-and-tuple-format-query/21052>\
**Category:** New to Julia\
**Created:** [February 21, 2019, 4:01pm UTC](https://discourse.julialang.org/t/println-and-tuple-format-query/21052 "2019-02-21T16:01:46Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Monkspeed](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/monkspeed/32/7131_2.png) [@Monkspeed](https://discourse.julialang.org/u/Monkspeed)\
**Post date:** [February 21, 2019, 4:01pm UTC](https://discourse.julialang.org/t/println-and-tuple-format-query/21052/1 "2019-02-21T16:01:46Z")

</div>

Hi all,

I’m trying to print out a tuple I have:

```julia
t1 = (9,6,5,2)
println("Tuple1, position1: $t1[1]")

```

but I receive an error because of the 1 inside the bracket, whats the correct way to format the statement?

Just to add, I have made the statement work just fine using

```julia
@printf("Tuple1, Position 1: %d", t1[1])

```

But I would also like to learn how to use it with println.

thanks!

---

<div class="post-metadata">

**Author:** ![mbauman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mbauman/32/31082_2.png) [@mbauman](https://discourse.julialang.org/u/mbauman)\
**Post date:** [February 21, 2019, 4:03pm UTC](https://discourse.julialang.org/t/println-and-tuple-format-query/21052/2 "2019-02-21T16:03:34Z")

</div>

You need parentheses to do the interpolation:

```julia
t1 = (9,6,5,2)
println("Tuple1, position1: $(t1[1])")

```

The interpolation only takes the very first thing it sees and no more — so `$foo(x)` just interpolates `foo` and not the function call. Same with indexing.

---

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [February 21, 2019, 4:13pm UTC](https://discourse.julialang.org/t/println-and-tuple-format-query/21052/3 "2019-02-21T16:13:00Z")

</div>

You can also use multiple arguments with println:

```julia
println("Tuple1, position1: “, t1[1])

```

---

<div class="post-metadata">

**Author:** ![Monkspeed](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/monkspeed/32/7131_2.png) [@Monkspeed](https://discourse.julialang.org/u/Monkspeed)\
**Post date:** [February 21, 2019, 4:15pm UTC](https://discourse.julialang.org/t/println-and-tuple-format-query/21052/4 "2019-02-21T16:15:03Z")

</div>

many thanks to you both!

Happy coding  
=D
