# How to print string with assigned variable and an "!" character?

**URL:** https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275
**Category:** New to Julia
**Tags:** strings
**Created:** [July 18, 2020, 4:12am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275 "2020-07-18T04:12:27Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![hismawan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hismawan/32/16465_2.png) [@hismawan](https://discourse.julialang.org/u/hismawan)
#### Post date: [July 18, 2020, 4:12am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/1 "2020-07-18T04:12:27Z")

</div>

I tried a simple code with julia:

x = readline()  
print(String(“Hello, $x!”))

and Julia took the variable as “x!”, instead of “x”.  
But, it was just fine when I changed the “!” with “.”

Is “!” a special character or else?

I need some explanation. Thank you!

---

<div class="post-metadata">

### Author: ![jishnub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jishnub/32/33620_2.png) [@jishnub](https://discourse.julialang.org/u/jishnub)
#### Post date: [July 18, 2020, 4:32am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/2 "2020-07-18T04:32:58Z")

</div>

> [@hismawan](#):
>
> print(String(“Hello, $x!”))

```julia
julia> x = 3; print(String("Hello, $(x)!"))
Hello, 3!

```

---

<div class="post-metadata">

### Author: ![WschW](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/wschw/32/6575_2.png) [@WschW](https://discourse.julialang.org/u/WschW)
#### Post date: [July 18, 2020, 4:36am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/3 "2020-07-18T04:36:27Z")

</div>

Nothing special about the `!` in this context. It is just that `x!` is a valid variable name.

---

<div class="post-metadata">

### Author: ![hismawan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hismawan/32/16465_2.png) [@hismawan](https://discourse.julialang.org/u/hismawan)
#### Post date: [July 18, 2020, 4:41am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/4 "2020-07-18T04:41:02Z")

</div>

Oh okay, that works . Thank you very much!

---

<div class="post-metadata">

### Author: ![hismawan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/hismawan/32/16465_2.png) [@hismawan](https://discourse.julialang.org/u/hismawan)
#### Post date: [July 18, 2020, 4:43am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/5 "2020-07-18T04:43:18Z")

</div>

Thank you for the answer. I didn’t know if Julia accept such “!” character as a valid variable, unlike Python.

---

<div class="post-metadata">

### Author: ![jling](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jling/32/212909_2.png) [@jling](https://discourse.julialang.org/u/jling)
#### Post date: [July 18, 2020, 4:46am UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/6 "2020-07-18T04:46:04Z")

</div>

you can see a lot of functions has `!` in them, such as `push!`, to hint an in-place operation or side-effect (non-pure).

---

<div class="post-metadata">

### Author: ![Henrique\_Becker](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/henrique_becker/32/15443_2.png) [@Henrique\_Becker](https://discourse.julialang.org/u/Henrique_Becker)
#### Post date: [July 18, 2020, 12:47pm UTC](https://discourse.julialang.org/t/how-to-print-string-with-assigned-variable-and-an-character/43275/7 "2020-07-18T12:47:58Z")

</div>

Perfect. But just to complement, it is worth mentioning that a valid function name is also a valid variable name. So what is seen in function names can also be seen in variable names.
