Beginner Python Global variables.Why do we use global variables?

<%= @topic_view.topic.title %>
<%= @topic_view.topic.average_rating %> <%= @topic_view.topic.posts.count { |p| !!p.custom_fields['rating'] } %>
a = "Hello"

def prints_a():
	print(a)
  
# will print "Hello"
prints_a()

What would happen in case we would use those global variable"a" inside the code?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

that it is not a global variable anymore, that it can’t be used by other functions.