wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
y = 64 | y=64 | No spaces. | Shell |
Write-Host 'hello' | Write-Host 'hello' | Correct. | PowerShell |
compute | compute() | Add parentheses. | Swift |
int items[14]; items[14]=5; | int items[14]; if(14<14){{}} else items[14]=5; | Bounds check. | C++ |
yield temp | yield temp | Correct yield. | Python |
int[] arr = new int[21];
arr[21] = 5; | int[] arr = new int[21];
if (21 < arr.length) arr[21] = 5; | Check bounds. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let b = 'result' | let b = "result" | Double quotes. | Swift |
list.forEach(function(temp) {{ console.log(temp); }}) | list.forEach((temp) => {{ console.log(temp); }}) | Arrow functions are cleaner. | JavaScript |
if y = 54 {{}} | if y == 54 {{}} | Use ==. | Swift |
SELECT * FROM items WHRE status=81; | SELECT * FROM items WHERE status=81; | Fix WHERE. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
for (int i=0; i<42; i++) {{}} | for (int i=0; i<42; i++) {{}} | Correct. | Java |
<p>output <b>world</p></b> | <p>output <b>world</b></p> | Nest properly. | HTML |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
def render():
print('value') | def render():
print('value') | Indent function body. | Python |
DELETE FROM products WHERE status=43 | DELETE FROM products WHERE status=43; | Add semicolon. | SQL |
if data = 85: | if data == 85: | Use == for comparison. | Python |
if ($x = 87) | if ($x == 87) | Use ==. | Perl |
object User {{ def main(args: Array[String]) = println("value") }} | object User {{ def main(args: Array[String]): Unit = println("value") }} | Add return type Unit. | Scala |
if temp = 48 | if temp == 48 | Use ==. | Ruby |
local item = 69 | local item = 69 | Correct. | Lua |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(9); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(9, () => console.log('listening')); | Add callback. | Node.js |
if ($b = 29) {{}} | if ($b -eq 29) {{}} | Use -eq. | PowerShell |
[87, 98, 19 | [87, 98, 19] | Close bracket. | Ruby |
'96' + 96 | 96 + 96 | Avoid string coercion. | JavaScript |
val foo = 'info' | val foo = "info" | Double quotes. | Kotlin |
disp('value') | disp('value') | Correct. | MATLAB |
function test(x:string){{return x;}} test(80); | function test(x:string){{return x;}} test('data'); | Pass correct type. | TypeScript |
let z: Int = 'output' | let z: String = 'output' | Fix type. | Swift |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{"id":"test",}} | {{"id":"test"}} | Remove trailing comma. | JSON |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if [ $index = 33 ]; then | if [ "$index" = 33 ]; then | Quote variable. | Shell |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
var x = 77; | var x = 77; | Correct. | Dart |
let y = 31; | let y = 31; | Correct. | JavaScript |
function compute(count)
print(count)
end | function compute(count)
print(count)
end | Correct. | Lua |
if ($bar = 65) | if ($bar == 65) | Use ==. | Perl |
if z = 12: | if z == 12: | Use == for comparison. | Python |
class Product {{ int c; }}; | class Product {{ public: int c; }}; | Make public. | C++ |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
if (foo = 92) {} | if (foo == 92) {} | Use ==. | Dart |
const temp; | const temp = 4; | Initialize const. | JavaScript |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
let temp: Int = 'test' | let temp: String = 'test' | Fix type. | Swift |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
Post.save(); | Post.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
function bar() {{
return
{{key:'data'}}
}} | function bar() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
println('data') | println("data") | Double quotes. | Scala |
val x = 25; x = 56 | var x = 25; x = 56 | Use var for reassignment. | Scala |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
my @arr = (100,10,46); | my @arr = (100,10,46); | Correct. | Perl |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
for y in range(89)
print(y) | for y in range(89):
print(y) | Colon after for. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
int* obj = nullptr; *obj=5; | int* obj = new int; *obj=5; | Allocate memory. | C++ |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
let c = 100; c += 1; | let mut c = 100; c += 1; | Need mut to modify. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
var x int = 'test' | var x string = 'test' | Type mismatch. | Go |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
try {{ throw 'test'; }} catch(e) {{}} | try {{ throw new Error('test'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
name: message
age: 34 | name: message
age: 34 | Correct. | YAML |
const foo = 23; foo = 47; | let foo = 23; foo = 47; | Cannot reassign const. | JavaScript |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
DELETE FROM products WHERE age=78 | DELETE FROM products WHERE age=78; | Add semicolon. | SQL |
value: value
name: data, | value: value
name: data | Remove comma. | YAML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
arr.forEach(function(item) {{ console.log(item); }}) | arr.forEach((item) => {{ console.log(item); }}) | Arrow functions are cleaner. | JavaScript |
if (num = 83) | if (num == 83) | Use ==. | C++ |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
{{'status':'info'}} | {{"status":"info"}} | Use double quotes. | JSON |
$items[18] = 5; | if (isset($items[18])) $items[18] = 5; | Check existence. | PHP |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
while temp > 15
temp -= 1 | while temp > 15:
temp -= 1 | Colon missing after while. | Python |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
WHERE id = '45' | WHERE id = 45 | Don't quote integer. | SQL |
def compute():
print('test') | def compute():
print('test') | Indent function body. | Python |
list(69) | if length(list) >= 69, list(69), end | Check length. | MATLAB |
h1 {{ font-size:66px color:#333; }} | h1 {{ font-size:66px; color:#333; }} | Add semicolon. | CSS |
function handle(c:string){{return c;}} handle(79); | function handle(c:string){{return c;}} handle('world'); | Pass correct type. | TypeScript |
<input type='text' value='result'> | <input type='text' value='result' name='age'> | Add name attribute. | HTML |
switch(bar){{ case 65: break; }} | switch(bar){{ case 65: break; default: break; }} | Add default case. | Java |
val = 93 | val=93 | No spaces. | Shell |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.