Computer Science, asked by dakshgirdhar11, 4 months ago

if you write anything you will be reported​

Attachments:

Answers

Answered by Equestriadash
15

Given cσde:

STRING = ""HAPPY NEW YEAR"

for S in range[0, 14]: print STRING(S)

STRING = STRING.lower

Corrected cσde:

STRING = "HAPPY NEW YEAR"     #correction 1

for S in range(0, 14):                        #correction 2

      print(STRING[S])                        #correction 3, correction 4

STRING = STRING.lower()              #correction 5

Explanation:

#correction 1

  • Original: STRING = ""HAPPY NEW YEAR"
  • Corrected: STRING = "HAPPY NEW YEAR"

Strings must be enclosed with the same type of quotes on both ends. There shouldn't be extra quotes before or after it.

#correction 2

  • Original: for S in range[0, 14]:
  • Corrected: for S in range(0, 14):

The range values must be given in round brackets and not square brackets.

#correction 3

  • Original: print STRING(S)
  • Corrected: print(STRING(S))

The argument for the print function must be placed within brackets.

Also, since the print function is given after a for loop command, the function must be properly indented.

#correction 4

  • Original: print(STRING(S))
  • Corrected: print(STRING[S])

Since 'S' is the traversing variable, 'S' must be placed within square brackets as it takes index values from 0 - 14 and displays each character in the string. When giving slice commands, the index values must be within square brackets.

#correction 5

  • Original: STRING = STRING.lower
  • Corrected: STRING = STRING.lower()

Brackets must be given along with string methods.


Anonymous: Awesome Diddu! :D
Equestriadash: Thank you! ╮(╯▽╰)╭
Equestriadash: Thanks for the Brainliest! ^_^"
Similar questions