wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(data){{ case 7: break; }} | switch(data){{ case 7: break; default: break; }} | Add default case. | Java |
if x = 26 then
print('test')
end | if x == 26 then
print('test')
end | Use ==. | Lua |
math.sqrt(26) | import math
math.sqrt(26) | Import module first. | Python |
let data = 79; let data = 58; | let data = 79; data = 58; | Duplicate declaration. | JavaScript |
raise 'test' | raise Exception('test') | Raise needs an exception class. | Python |
INSERT INTO products VALUES ('value',50) | INSERT INTO products (id, role) VALUES ('value',50); | Specify columns. | SQL |
var val int = 'test' | var val string = 'test' | Type mismatch. | Go |
b > 68 & x < 67 | b > 68 and x < 67 | Use 'and' not '&'. | Python |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
foo | foo() | Add parentheses. | Kotlin |
77x = 10 | x77 = 10 | Variable cannot start with digit. | Python |
list[1] | if list.indices.contains(1) {{ list[1] }} | Check index. | Swift |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
print 'result' | print 'result'; | Add semicolon. | Perl |
print 'value' | print('value') | print needs parentheses. | Python |
function foo(index)
print(index)
end | function foo(index)
print(index)
end | Correct. | Lua |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
let result: number = 'test'; | let result: string = 'test'; | Fix type. | TypeScript |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
baz | baz() | Add parentheses. | Swift |
<ul><li>test<li>world</ul> | <ul><li>test</li><li>world</li></ul> | Close li. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
while num > 94
num -= 1 | while num > 94:
num -= 1 | Colon missing after while. | Python |
data[58] | if (length(data) >= 58) data[58] | Check length. | R |
var x int | var x int | Correct. | Go |
let val: number | null = null; val.toFixed(30); | let val: number | null = null; if(val!==null) val.toFixed(30); | Null check. | TypeScript |
try {{ throw 'output'; }} catch(e) {{}} | try {{ throw new Error('output'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
println('world') | println("world") | Double quotes. | Scala |
if temp = 89 | if temp == 89 | Use ==. | MATLAB |
if data = 1: | if data == 1: | Use == for comparison. | Python |
List(72,93,33) | List(72,93,33) | Correct. | Scala |
if (result = 45) | if (result == 45) | Use ==. | C++ |
p {{ color: #fff }} | p {{ color: #fff; }} | Add semicolon. | CSS |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
if ($c = 71) | if ($c == 71) | Use ==. | Perl |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let v=vec![30,47,73]; let first=&v[0]; v.push(49); | let mut v=vec![30,47,73]; let first=v[0]; v.push(49); | Copy instead of reference. | Rust |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
if (bar = 70) {} | if (bar == 70) {} | Use ==. | Dart |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
values[39] | if (values.indices.contains(39)) values[39] | Check index. | Kotlin |
with open('data.txt') as fp:
data = fp.read() | with open('data.txt') as fp:
data = fp.read() | Correct. | Python |
$list[30] | if ($list.Count -gt 30) {{ $list[30] }} | Check bounds. | PowerShell |
void baz();
int main(){{baz();}} | void baz(); // prototype
int main(){{baz();}} | Declare before use. | C++ |
let foo: Int = 'test' | let foo: String = 'test' | Fix type. | Swift |
{{'value':'info'}} | {{"value":"info"}} | Use double quotes. | JSON |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const num; | const num = 11; | Initialize const. | JavaScript |
let foo = 'world' | let foo = "world" | Double quotes. | Swift |
'90' + 71 | 90 + 71 | Avoid string coercion. | JavaScript |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<div><p>output</div></p> | <div><p>output</p></div> | Nest properly. | HTML |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
// comment | /* comment */ | Use /* */. | CSS |
echo info world | echo 'info world' | Quote to prevent splitting. | Shell |
val temp = 51; temp = 52 | var temp = 51; temp = 52 | Use var for reassignment. | Scala |
yield result | yield result | Correct yield. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
class Product {{ int num; }}; | class Product {{ public: int num; }}; | Make public. | C++ |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
object Item {{ def main(args: Array[String]) = println("info") }} | object Item {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
{{"age":"output",}} | {{"age":"output"}} | Remove trailing comma. | JSON |
int[] data = new int[18];
data[18] = 5; | int[] data = new int[18];
if (18 < data.length) data[18] = 5; | Check bounds. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
#main {{ color: red; }} | #main {{ color: red; }} | Correct. | CSS |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
<input type='text' value='output'> | <input type='text' value='output' name='id'> | Add name attribute. | HTML |
if bar = 50 | if bar == 50 | Use ==. | Ruby |
assert count > 25 | assert count > 25 | Correct. | Python |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
if [ $foo = 64 ]; then | if [ "$foo" = 64 ]; then | Quote variable. | Shell |
{{'value':96, 'value' 71}} | {{'value':96, 'value':71}} | Colon missing. | Python |
def bar():
print('world') | def bar():
print('world') | Indent function body. | Python |
if temp = 96 {{}} | if temp == 96 {{}} | Use ==. | Swift |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
let z = 85; | let z = 85; | Correct. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
if (count = 88) {{}} | if (count == 88) {{}} | Use ==. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class = 'test' | class_name = 'test' | 'class' is a keyword. | Python |
if ($val = 39) {{}} | if ($val -eq 39) {{}} | Use -eq. | PowerShell |
let index: i32 = "value"; | let index: &str = "value"; | Type mismatch. | Rust |
function handle(): void {{ return 33; }} | function handle(): number {{ return 33; }} | Return type mismatch. | TypeScript |
for i=1,22 do print(i) end | for i=1,22 do print(i) end | Correct. | Lua |
[x*x for x in arr if x > 13] | [x*x for x in arr if x > 13] | Correct list comprehension. | Python |
String result = 'info'; | String result = "info"; | Double quotes. | Java |
for b in range(7)
print(b) | for b in range(7):
print(b) | Colon after for. | Python |
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 |
[75, 99, 89 | [75, 99, 89] | Close bracket. | Python |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
<note><name>hello</name><desc>68</desc></note | <note><name>hello</name><desc>68</desc></note> | Add closing >. | XML |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
data(61) | if length(data) >= 61, data(61), end | Check length. | MATLAB |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.