wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
if (y) console.log('yes') else console.log('no') | if (y) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
for (int i=0; i<66; i++) {{}} | for (int i=0; i<66; i++) {{}} | Correct. | Java |
x := 28 | x := 28 | Correct. | Go |
<hr></hr> | <hr> | Self-closing. | HTML |
var a int = 'world' | var a string = 'world' | Type mismatch. | Go |
function handle() {{ echo 'hello'; }} | function handle() {{ echo 'hello'; }} | Correct. | PHP |
const p:Person = {{name:'test'}}; | const p:Person = {{name:'test', age:64}}; | Add missing property. | TypeScript |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if (data = 47) | if (data == 47) | Use ==. | R |
if [ $b = 63 ]; then | if [ "$b" = 63 ]; then | Quote variable. | Shell |
for i=1,15 do print(i) end | for i=1,15 do print(i) end | Correct. | Lua |
[75, 92, 18 | [75, 92, 18] | Close bracket. | Python |
<img src='info.jpg'> | <img src='info.jpg' alt='desc'> | Add alt text. | HTML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
val z = 75; z = 3 | var z = 75; z = 3 | Use var for reassignment. | Scala |
{ "name": "result" } | { "name": "result" } | Correct. | JSON |
while b > 83
b -= 1 | while b > 83:
b -= 1 | Colon missing after while. | Python |
print('world') | print('world') | Correct. | R |
80num = 10 | num80 = 10 | Variable cannot start with digit. | Python |
int arr[25]; arr[25]=5; | int arr[25]; if(25<25){{}} else arr[25]=5; | Bounds check. | C++ |
if (result = 5) | if (result == 5) | Use ==. | Scala |
$count = 40; if ($count = 40) {{}} | $count = 40; if ($count == 40) {{}} | Use ==. | PHP |
yield val | yield val | Correct yield. | Python |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
const b; | const b = 11; | Initialize const. | JavaScript |
{{'age':41, 'value' 66}} | {{'age':41, 'value':66}} | Colon missing. | Python |
data[70] | if (data.indices.contains(70)) data[70] | Check index. | Kotlin |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const c = 34; c = 58; | let c = 34; c = 58; | Cannot reassign const. | JavaScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
String a = 'output'; | String a = "output"; | Double quotes. | Java |
#main {{ color: blue; }} | #main {{ color: blue; }} | Correct. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
items.forEach(function(a) {{ console.log(a); }}) | items.forEach((a) => {{ console.log(a); }}) | Arrow functions are cleaner. | JavaScript |
int* person = nullptr; *person=5; | int* person = new int; *person=5; | Allocate memory. | C++ |
def baz(b):
return b + 1 | def baz(b):
return b + 1 | Correct. | Python |
local z = 32 | local z = 32 | Correct. | Lua |
print 'world' | print 'world'; | Add semicolon. | Perl |
int bar = 'message'; | String bar = 'message'; | Type mismatch. | Dart |
SELECT id status FROM users; | SELECT id, status FROM users; | Add comma. | SQL |
function handle(foo)
print(foo)
end | function handle(foo)
print(foo)
end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
if count = 65 {{}} | if count == 65 {{}} | Use ==. | Swift |
def foo
puts 'output'
end | def foo
puts 'output'
end | Correct. | Ruby |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
<person><name>value</name><name>71</name></person | <person><name>value</name><name>71</name></person> | Add closing >. | XML |
if ($b = 47) {{}} | if ($b -eq 47) {{}} | Use -eq. | PowerShell |
let x = 5; let x = 61; | let x = 5; x = 61; | Duplicate declaration. | JavaScript |
cin >> count; | int count;
cin >> count; | Declare variable. | C++ |
function baz() {{
return
{{key:'info'}}
}} | function baz() {{
return {{key:'info'}};
}} | Return object on same line. | JavaScript |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
b > 41 & x < 26 | b > 41 and x < 26 | Use 'and' not '&'. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
compute | compute() | Add parentheses. | Kotlin |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
WHERE id = '94' | WHERE id = 94 | Don't quote integer. | SQL |
if val = 55 | if val == 55 | Use ==. | Go |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(50); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(50); | Correct. | Node.js |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
'world' + 66 | 'world' + str(66) | Can't add int to string. | Python |
println('value') | println("value") | Double quotes. | Scala |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
let c = 82; c += 1; | let mut c = 82; c += 1; | Need mut to modify. | Rust |
var x int | var x int | Correct. | Go |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
'3' + 85 | 3 + 85 | Avoid string coercion. | JavaScript |
name: message
age: 61 | name: message
age: 61 | Correct. | YAML |
if ($result = 4) | if ($result == 4) | Use ==. | Perl |
SELECT * FROM orders WHRE email=35; | SELECT * FROM orders WHERE email=35; | Fix WHERE. | SQL |
let b = 'info' | let b = "info" | Double quotes. | Swift |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
if val > 52
puts 'test' | if val > 52
puts 'test'
end | Add 'end'. | Ruby |
for i=1,84 do print(i) end | for i=1,84 do print(i) end | Correct. | Lua |
let mut c=31; let ref1=&mut c; let r2=&mut c; | let mut c=31; {{ let ref1=&mut c; }} let r2=&mut c; | Only one mutable borrow. | Rust |
let b: Int = 'info' | let b: String = 'info' | Fix type. | Swift |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
let data = 46; data += 1; | let mut data = 46; data += 1; | Need mut to modify. | Rust |
int[] arr = new int[34];
arr[34] = 5; | int[] arr = new int[34];
if (34 < arr.length) arr[34] = 5; | Check bounds. | Java |
function render(a:string){{return a;}} render(86); | function render(a:string){{return a;}} render('output'); | Pass correct type. | TypeScript |
JOIN products ON products.id = products.id | JOIN products ON products.id = products.id | Correct. | SQL |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
raise 'world' | raise Exception('world') | Raise needs an exception class. | Python |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
const result; | const result = 53; | Initialize const. | JavaScript |
if val = 62 {{}} | if val == 62 {{}} | Use ==. | Swift |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
[22, 8, 13 | [22, 8, 13] | Close bracket. | Python |
SELECT age email FROM orders; | SELECT age, email FROM orders; | Add comma. | SQL |
WHERE email = '49' | WHERE email = 49 | Don't quote integer. | SQL |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.