0

I'm new to VS Code. I run simple function in Python and want to see output. I use "Debug" -> "Start Debugging".

def double_char_function(string): string = 'abc' return_string = '' for char in string: return_string += char*2 return return_string 

I want to see the output:

aabbcc

I saw it when I run it. But don't know how to see it again. Please, help me to use VS Code.

Screenshots:

  1. Terminal output
  2. Output is empty

Kind regards, Anna

2
  • 4
    You're never calling your function. You need to call double_char_function with a string for it to process, and then print out what it returns. Commented Mar 29, 2021 at 13:51
  • @Carcigenicate Thank you. I have my function giving me output now Commented Mar 29, 2021 at 17:19

3 Answers 3

1

Try:

def double_char_function(string): return_string = '' for char in string: return_string += char*2 return return_string print(double_char_function('abc')) 
Sign up to request clarification or add additional context in comments.

Comments

0

Apart from the solutions provided above, I'd recommend you to learn the basics from a YouTube tutorial (eg. tutorials by CoreyMS, Mosh, etc), since it's always better to learn systematically especially for a beginner.

1 Comment

Thank you, I checked CoreyMS tutorials
0

Try:

def double_char_function(string): return_string = '' for char in string: return_string += char*2 return return_string string = "Hello!" print(double_char_function(string)) 

1 Comment

This doesn't adds anything extra to @Álvaro Navarro Torres's answer

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.