# How do I exit a function early and return nothing?

**URL:** <https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078>\
**Category:** General Usage\
**Tags:** dataframes, function\
**Created:** [February 25, 2022, 3:39pm UTC](https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078 "2022-02-25T15:39:13Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![a.frist](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@a.frist](https://discourse.julialang.org/u/a.frist)\
**Post date:** [February 25, 2022, 3:39pm UTC](https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078/1 "2022-02-25T15:39:13Z")

</div>

I have a function that takes a dataframe and performs some basic calculations. Sometimes when performing said calculations the data frame becomes empty (the details don’t matter). I’m having trouble checking if the dataframe is empty and returning nothing. My code is below:

```julia
function do_stuff(my_dataframe)

    # Nifty calculations

    if nrow(my_dataframe) == 0:

        return

    # More calculations here

    return my_datafram

end

```

For some reason, julia is throwing this error: LoadError: syntax: incomplete: “function” at /home/ec2-user/environment/my\_file.jl:17 requires end

Is there a syntax error? Is there a proper way to interrupt a function?

---

<div class="post-metadata">

**Author:** ![pdeffebach](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/pdeffebach/32/10320_2.png) [@pdeffebach](https://discourse.julialang.org/u/pdeffebach)\
**Post date:** [February 25, 2022, 3:47pm UTC](https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078/2 "2022-02-25T15:47:19Z")

</div>

Your syntax is wrong. Julia does not have the same syntax as python. `if` statements are not whitespace sensitive and need an `end` to complete the block.

You should try to work. See [this section](https://docs.julialang.org/en/v1/manual/control-flow/#man-conditional-evaluation) in the manual. Hopefully someone else here can recommend to you are good introductory tutorial for people coming from python.

---

<div class="post-metadata">

**Author:** ![a.frist](https://avatars.discourse-cdn.com/v4/letter/a/d26b3c/32.png) [@a.frist](https://discourse.julialang.org/u/a.frist)\
**Post date:** [February 25, 2022, 4:08pm UTC](https://discourse.julialang.org/t/how-do-i-exit-a-function-early-and-return-nothing/77078/3 "2022-02-25T16:08:25Z")

</div>

My code is working now, thank you! I thought the “end” blocks only applied to functions. I need to read the manual more carefully.
