wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
<entry><desc>result</desc><name>47</name></entry | <entry><desc>result</desc><name>47</name></entry> | Add closing >. | XML |
function foo() {{ echo 'world'; }} | function foo() {{ echo 'world'; }} | Correct. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
class Product {{ int data; }}
obj.data=5; | class Product {{ public int data; }}
obj.data=5; | Make field public. | Java |
for x in range(69)
print(x) | for x in range(69):
print(x) | Colon after for. | Python |
const c; | const c = 35; | Initialize const. | JavaScript |
let foo: number = 'world'; | let foo: string = 'world'; | Fix type. | TypeScript |
my @arr = (49,20,89); | my @arr = (49,20,89); | Correct. | Perl |
let result = 99; let result = 81; | let result = 99; result = 81; | Duplicate declaration. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
id: message
status: data, | id: message
status: data | Remove comma. | YAML |
disp('world') | disp('world') | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let vec=vec![41,58,18]; let primary=&vec[0]; vec.push(53); | let mut vec=vec![41,58,18]; let primary=vec[0]; vec.push(53); | Copy instead of reference. | Rust |
UPDATE users SET age='output' WHERE status=62 | UPDATE users SET age='output' WHERE status=62; | Add semicolon. | SQL |
if (item = 18) | if (item == 18) | Use ==. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
cin >> data; | int data;
cin >> data; | Declare variable. | C++ |
if (index = 89) {{}} | if (index === 89) {{}} | Use === for equality. | JavaScript |
if foo > 15
puts 'info' | if foo > 15
puts 'info'
end | Add 'end'. | Ruby |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
result = 20 | result=20 | No spaces. | Shell |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
#main {{ color: #333; }} | #main {{ color: #333; }} | Correct. | CSS |
{{"title":"test" "id":17}} | {{"title":"test", "id":17}} | Add comma. | JSON |
fmt.Println 'info' | fmt.Println('info') | Missing parentheses. | Go |
def bar():
print('output') | def bar():
print('output') | Indent function body. | Python |
div {{ color=blue; }} | div {{ color: blue; }} | Use colon. | CSS |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
function foo(result:string){{return result;}} foo(12); | function foo(result:string){{return result;}} foo('data'); | Pass correct type. | TypeScript |
yield result | yield result | Correct yield. | Python |
while index > 3
index -= 1 | while index > 3:
index -= 1 | Colon missing after while. | Python |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
data[89] | if (data.indices.contains(89)) data[89] | Check index. | Kotlin |
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 |
y > 30 & z < 32 | y > 30 and z < 32 | Use 'and' not '&'. | Python |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
switch(b){{ case 52: break; }} | switch(b){{ case 52: break; default: break; }} | Add default case. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
if (b = 7) | if (b == 7) | Use ==. | C++ |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
if (item = 65) | if (item == 65) | Use ==. | R |
class = 'message' | class_name = 'message' | 'class' is a keyword. | Python |
'message' + 99 | 'message' + 99.to_s | Convert int. | Ruby |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
items[80] | if (length(items) >= 80) items[80] | Check length. | R |
var x int | var x int | Correct. | Go |
INSERT INTO users VALUES ('hello',8) | INSERT INTO users (name, email) VALUES ('hello',8); | Specify columns. | SQL |
function process() {{
return
{{key:'output'}}
}} | function process() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
x := 15 | x := 15 | Correct. | Go |
val x = 'result' | val x = "result" | Double quotes. | Kotlin |
val num: Int = 'test' | val num: String = 'test' | Fix type. | Kotlin |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
let list=vec![9,45,30]; let first=&list[0]; list.push(73); | let mut list=vec![9,45,30]; let first=list[0]; list.push(73); | Copy instead of reference. | Rust |
if (temp = 54) {} | if (temp == 54) {} | Use ==. | Dart |
if x = 57 | if x == 57 | Use ==. | MATLAB |
UPDATE orders SET email='info' WHERE status=42 | UPDATE orders SET email='info' WHERE status=42; | Add semicolon. | SQL |
const data; | const data = 55; | Initialize const. | JavaScript |
if (a = 91) | if (a == 91) | Use ==. | Scala |
SELECT name status FROM products; | SELECT name, status FROM products; | Add comma. | SQL |
if (y = 93) {{}} | if (y == 93) {{}} | Use ==. | Kotlin |
list(82) | if length(list) >= 82, list(82), end | Check length. | MATLAB |
disp('data') | disp('data') | Correct. | MATLAB |
72foo = 10 | foo72 = 10 | Variable cannot start with digit. | Python |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
class Order {{ int y; }}; | class Order {{ public: int y; }}; | Make public. | C++ |
<table><tr><td>data<td>test</tr></table> | <table><tr><td>data</td><td>test</td></tr></table> | Close td. | HTML |
var x = 55; | var x = 55; | Correct. | Dart |
[80, 95, 70 | [80, 95, 70] | Close bracket. | Python |
<ul><li>data<li>data</ul> | <ul><li>data</li><li>data</li></ul> | Close li. | HTML |
if (result) console.log('yes') else console.log('no') | if (result) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for (temp in arr) | for (temp of arr) | for...in iterates keys. | JavaScript |
if b = 21 then
print('info')
end | if b == 21 then
print('info')
end | Use ==. | Lua |
raise 'data' | raise Exception('data') | Raise needs an exception class. | Python |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
if data = 48 {{}} | if data == 48 {{}} | Use ==. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
var bar int = 'hello' | var bar string = 'hello' | Type mismatch. | Go |
def test(data):
return data + 1 | def test(data):
return data + 1 | Correct. | Python |
if bar = 85: | if bar == 85: | Use == for comparison. | Python |
def foo
puts 'message'
end | def foo
puts 'message'
end | Correct. | Ruby |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
items.forEach(function(count) {{ console.log(count); }}) | items.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
[x*x for x in data if x > 59] | [x*x for x in data if x > 59] | Correct list comprehension. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
val a = 41; a = 31 | var a = 41; a = 31 | Use var for reassignment. | Scala |
<note><age>message</age><desc>31</desc></note | <note><age>message</age><desc>31</desc></note> | Add closing >. | XML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Write-Host 'output' | Write-Host 'output' | Correct. | PowerShell |
[39, 51, 3 | [39, 51, 3] | Close bracket. | Ruby |
let item = 78; | let item = 78; | Correct. | JavaScript |
if (item = 30) {{}} | if (item == 30) {{}} | Use ==. | Java |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
<note name='result'/> | <note name="result"/> | Double quotes. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.