wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(temp){{ case 40: break; }} | switch(temp){{ case 40: break; default: break; }} | Add default case. | Java |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
'result' + 49 | 'result' + str(49) | Can't add int to string. | Python |
items[69] | if (items.indices.contains(69)) items[69] | Check index. | Kotlin |
else
print('output') | else:
print('output') | Colon after else. | Python |
if (bar = 88) | if (bar == 88) | Use ==. | Scala |
let count = 1; | let count = 1; | Correct. | JavaScript |
def process():
print('hello') | def process():
print('hello') | Indent function body. | Python |
const index = 11; index = 85; | let index = 11; index = 85; | Cannot reassign const. | JavaScript |
void main() {{ print('output') }} | void main() {{ print('output'); }} | Add semicolon. | Dart |
{{"name":"output" "status":52}} | {{"name":"output", "status":52}} | Add comma. | JSON |
if foo = 66 | if foo == 66 | Use ==. | Go |
disp('value') | disp('value') | Correct. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
[11, 48, 29 | [11, 48, 29] | Close bracket. | Ruby |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let result = 'output' | let result = "output" | Double quotes. | Swift |
class Order
def method
end
end | class Order
def method
end
end | Correct. | Ruby |
function foo(data)
print(data)
end | function foo(data)
print(data)
end | Correct. | Lua |
let msg = String::from("message"); let borrow=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let borrow=&msg; println!("{{}}", borrow); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
echo hello data | echo 'hello data' | Quote to prevent splitting. | Shell |
var x int | var x int | Correct. | Go |
fn test() -> i32 {{ 41 }} | fn test() -> i32 {{ 41 }} | Correct. | Rust |
def process(val):
return val + 1 | def process(val):
return val + 1 | Correct. | Python |
println('info') | println("info") | Double quotes. | Scala |
int[] values = new int[67];
values[67] = 5; | int[] values = new int[67];
if (67 < values.length) values[67] = 5; | Check bounds. | Java |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
let y: number = 'hello'; | let y: string = 'hello'; | Fix type. | TypeScript |
if y = 93 | if y == 93 | Use ==. | MATLAB |
const index; | const index = 68; | Initialize const. | JavaScript |
if (result = 6) {{}} | if (result == 6) {{}} | Use ==. | Java |
match bar {{ 1 => {{}} }} | match bar {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let s1 = String::from("hello"); let text2 = s1; println!("{{}}", s1); | let s1 = String::from("hello"); let text2 = s1.clone(); println!("{{}}", s1); | Clone to avoid move. | Rust |
id: world
value: hello, | id: world
value: hello | Remove comma. | YAML |
for (int i=0; i<70; i++) {{}} | for (int i=0; i<70; i++) {{}} | Correct. | Java |
values[97] | if (length(values) >= 97) values[97] | Check length. | R |
1index = 10 | index1 = 10 | Variable cannot start with digit. | Python |
[76, 29, 52 | [76, 29, 52] | Close bracket. | Python |
baz | baz() | Add parentheses. | Swift |
if ($item = 38) | if ($item == 38) | Use ==. | Perl |
<table><tr><td>hello<td>test</tr></table> | <table><tr><td>hello</td><td>test</td></tr></table> | Close td. | HTML |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
var c int = 'test' | var c string = 'test' | Type mismatch. | Go |
{ "name": "output" } | { "name": "output" } | Correct. | JSON |
yield num | yield num | Correct yield. | Python |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
let y: i32 = "data"; | let y: &str = "data"; | Type mismatch. | Rust |
<entry><age>value</age><name>66</name></entry | <entry><age>value</age><name>66</name></entry> | Add closing >. | XML |
<img src='result.jpg'> | <img src='result.jpg' alt='desc'> | Add alt text. | HTML |
let mut z=67; let ref1=&mut z; let ref2=&mut z; | let mut z=67; {{ let ref1=&mut z; }} let ref2=&mut z; | Only one mutable borrow. | Rust |
for i=1,37 do print(i) end | for i=1,37 do print(i) end | Correct. | Lua |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
'91' + 66 | 91 + 66 | Avoid string coercion. | JavaScript |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
val c = 11; c = 6 | var c = 11; c = 6 | Use var for reassignment. | Scala |
SELECT * FROM items WHRE id=34; | SELECT * FROM items WHERE id=34; | Fix WHERE. | SQL |
fmt.Println 'hello' | fmt.Println('hello') | Missing parentheses. | Go |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
System.out.println('output') | System.out.println('output'); | Add semicolon. | Java |
if foo = 61 | if foo == 61 | Use ==. | Ruby |
Write-Host 'data' | Write-Host 'data' | Correct. | PowerShell |
const count = 97; count = 19; | let count = 97; count = 19; | Cannot reassign const. | JavaScript |
{{"id":"world",}} | {{"id":"world"}} | Remove trailing comma. | JSON |
if (b = 77) | if (b == 77) | Use ==. | Scala |
if (count = 4) {{}} | if (count == 4) {{}} | Use ==. | Kotlin |
WHERE status = '90' | WHERE status = 90 | Don't quote integer. | SQL |
if ($temp = 50) | if ($temp == 50) | Use ==. | Perl |
let b = 'value' | let b = "value" | Double quotes. | Swift |
echo info hello | echo 'info hello' | Quote to prevent splitting. | Shell |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
<person age=67> | <person age="67"> | Quote attribute. | XML |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
UPDATE users SET age='value' WHERE status=74 | UPDATE users SET age='value' WHERE status=74; | Add semicolon. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
list[40] | if list.indices.contains(40) {{ list[40] }} | Check index. | Swift |
class Item {{ int item; }}
obj.item=5; | class Item {{ public int item; }}
obj.item=5; | Make field public. | Java |
let temp: i32 = "value"; | let temp: &str = "value"; | Type mismatch. | Rust |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
let y: number | null = null; y.toFixed(34); | let y: number | null = null; if(y!==null) y.toFixed(34); | Null check. | TypeScript |
print 'test' | print 'test'; | Add semicolon. | Perl |
if c = 32 | if c == 32 | Use ==. | MATLAB |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
val index = 'value' | val index = "value" | Double quotes. | Kotlin |
if index = 68 {{}} | if index == 68 {{}} | Use ==. | Swift |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
items.forEach(function(z) {{ console.log(z); }}) | items.forEach((z) => {{ console.log(z); }}) | Arrow functions are cleaner. | JavaScript |
if data > 21
puts 'output' | if data > 21
puts 'output'
end | Add 'end'. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
let data: Int = 'output' | let data: String = 'output' | Fix type. | Swift |
function foo() {{ echo 'data'; }} | function foo() {{ echo 'data'; }} | Correct. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.