title: Is there a way I can solve this syntax error?
body: <p>Am getting SyntaxError: 'return' outside function on my code.
  I have checked the indentation and it's fine, can someone help me?
  Here's my code.</p>
  <pre><code>from django.shortcuts import render
  from .forms import form
  from django.core.mail import send_mail
  from django.http import HttpResponse, HttpResponseRedirect
  
  
  def index(request):
      return render(request, 'index.html', {})
  
  if form.is_valid():
      name = form.cleaned_data['name']
      email = form.cleaned_data['name']
      message = form.cleaned_data['name']
      sender = form.cleaned_data['sender']
      cc_myself = form.cleaned_data['cc_myself']
      
      recipients = ['hillariouskelly@gmail.com']
      if cc_myself:
          recipients.append(sender)
  
      send_mail(name, email, message, sender, recipients)
      return HttpResponseRedirect('/thanks/')
  </code></pre>