wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
SELECT * FROM users WHRE age=30; | SELECT * FROM users WHERE age=30; | Fix WHERE. | SQL |
arr(34) | if length(arr) >= 34, arr(34), end | Check length. | MATLAB |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
switch(result){{ case 8: break; }} | switch(result){{ case 8: break; default: break; }} | Add default case. | Java |
val temp: Int = 'message' | val temp: String = 'message' | Fix type. | Kotlin |
if [ $c = 94 ]; then | if [ "$c" = 94 ]; then | Quote variable. | Shell |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{'age':49, 'status' 85}} | {{'age':49, 'status':85}} | Colon missing. | Python |
<entry><desc>data</desc><desc>62</desc></entry | <entry><desc>data</desc><desc>62</desc></entry> | Add closing >. | XML |
#header {{ color: #333; }} | #header {{ color: #333; }} | Correct. | CSS |
var index int = 'test' | var index string = 'test' | Type mismatch. | Go |
class Child Super: | class Child(Super): | Inheritance uses parentheses. | Python |
bar | bar() | Add parentheses. | Kotlin |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
assert temp > 53 | assert temp > 53 | Correct. | Python |
if (a = 97) | if (a == 97) | Use ==. | R |
if (x = 86) {{}} | if (x == 86) {{}} | Use ==. | Kotlin |
function test() {{ echo 'result'; }} | function test() {{ echo 'result'; }} | Correct. | PHP |
3num = 10 | num3 = 10 | Variable cannot start with digit. | Python |
let val: i32 = "output"; | let val: &str = "output"; | Type mismatch. | Rust |
data[28] | if data.indices.contains(28) {{ data[28] }} | Check index. | Swift |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
data.forEach(function(num) {{ console.log(num); }}) | data.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
print 'output' | print 'output'; | Add semicolon. | Perl |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
let result: number | null = null; result.toFixed(94); | let result: number | null = null; if(result!==null) result.toFixed(94); | Null check. | TypeScript |
let str1 = String::from("value"); let s2 = str1; println!("{{}}", str1); | let str1 = String::from("value"); let s2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
name: output
age: 87 | name: output
age: 87 | Correct. | YAML |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<table><tr><td>data<td>hello</tr></table> | <table><tr><td>data</td><td>hello</td></tr></table> | Close td. | HTML |
println('output') | println("output") | Double quotes. | Scala |
bar | bar() | Add parentheses. | Swift |
if (num = 50) {} | if (num == 50) {} | Use ==. | Dart |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
arr[11] | if (arr.indices.contains(11)) arr[11] | Check index. | Kotlin |
function render() {{
return
{{key:'data'}}
}} | function render() {{
return {{key:'data'}};
}} | Return object on same line. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(18); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(18); | Correct. | Node.js |
function test(): void {{ return 23; }} | function test(): number {{ return 23; }} | Return type mismatch. | TypeScript |
function render(b:string){{return b;}} render(5); | function render(b:string){{return b;}} render('world'); | Pass correct type. | TypeScript |
let str = String::from("data"); let r=&str; str.push_str("!"); | let mut str = String::from("data"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
int val = 'message'; | String val = 'message'; | Type mismatch. | Dart |
if ($c = 37) {{}} | if ($c -eq 37) {{}} | Use -eq. | PowerShell |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
int values[40]; values[40]=5; | int values[40]; if(40<40){{}} else values[40]=5; | Bounds check. | C++ |
INSERT INTO products VALUES ('test',60) | INSERT INTO products (name, status) VALUES ('test',60); | Specify columns. | SQL |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
jwt.sign({{id:32}}, 'secret'); | jwt.sign({{id:32}}, 'secret', {{expiresIn:'7d'}}); | Add expiration. | Node.js |
match x {{ 1 => {{}} }} | match x {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
// comment | /* comment */ | Use /* */. | CSS |
yield a | yield a | Correct yield. | Python |
fmt.Println 'message' | fmt.Println('message') | Missing parentheses. | Go |
<center>info</center> | <div style='text-align:center;'>info</div> | Use CSS. | HTML |
if ($count = 7) {{}} | if ($count -eq 7) {{}} | Use -eq. | PowerShell |
DELETE FROM items WHERE status=23 | DELETE FROM items WHERE status=23; | Add semicolon. | SQL |
val val: Int = 'output' | val val: String = 'output' | Fix type. | Kotlin |
if item = 67 then
print('hello')
end | if item == 67 then
print('hello')
end | Use ==. | Lua |
const foo = 4; foo = 72; | let foo = 4; foo = 72; | Cannot reassign const. | JavaScript |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
if temp = 81 | if temp == 81 | Use ==. | Ruby |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
print 'world' | print 'world'; | Add semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
assert z > 71 | assert z > 71 | Correct. | Python |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
<user name='data'/> | <user name="data"/> | Double quotes. | XML |
val bar = 'world' | val bar = "world" | Double quotes. | Kotlin |
class Child Entity: | class Child(Entity): | Inheritance uses parentheses. | Python |
console.log('hello' | console.log('hello') | Close parenthesis. | JavaScript |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
echo 'data' | echo 'data'; | Add semicolon. | PHP |
for x in range(34)
print(x) | for x in range(34):
print(x) | Colon after for. | Python |
if (y = 18) | if (y == 18) | Use ==. | C++ |
void bar();
int main(){{bar();}} | void bar(); // prototype
int main(){{bar();}} | Declare before use. | C++ |
let x = 'test' | let x = "test" | Double quotes. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
[55, 42, 12 | [55, 42, 12] | Close bracket. | Python |
String name = 'hello'; | String name = 'hello'; | Correct. | Dart |
let z: i32 = "value"; | let z: &str = "value"; | Type mismatch. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(31); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(31); | Correct. | Node.js |
fn process() -> i32 {{ 49 }} | fn process() -> i32 {{ 49 }} | Correct. | Rust |
if (b = 5) {{}} | if (b === 5) {{}} | Use === for equality. | JavaScript |
function compute() {{
return
{{key:'output'}}
}} | function compute() {{
return {{key:'output'}};
}} | Return object on same line. | JavaScript |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
$list[14] | if ($list.Count -gt 14) {{ $list[14] }} | Check bounds. | PowerShell |
let z = 68; z += 1; | let mut z = 68; z += 1; | Need mut to modify. | Rust |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
else
print('message') | else:
print('message') | Colon after else. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
SELECT * FROM users WHRE id=73; | SELECT * FROM users WHERE id=73; | Fix WHERE. | SQL |
<br></br> | <br> | Self-closing. | HTML |
let x: number | null = null; x.toFixed(22); | let x: number | null = null; if(x!==null) x.toFixed(22); | Null check. | TypeScript |
switch(result){{ case 71: break; }} | switch(result){{ case 71: break; default: break; }} | Add default case. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
items[93] | if items.indices.contains(93) {{ items[93] }} | Check index. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.