wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
h1 {{ font-size:23px color:red; }} | h1 {{ font-size:23px; color:red; }} | Add semicolon. | CSS |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
const x; | const x = 7; | Initialize const. | JavaScript |
if data = 51 | if data == 51 | Use ==. | Ruby |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
print 'test' | print 'test'; | Add semicolon. | Perl |
'85' + 25 | 85 + 25 | Avoid string coercion. | JavaScript |
<input type='text' value='world'> | <input type='text' value='world' name='age'> | Add name attribute. | HTML |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
<ul><li>test<li>hello</ul> | <ul><li>test</li><li>hello</li></ul> | Close li. | HTML |
$data[45] = 5; | if (isset($data[45])) $data[45] = 5; | Check existence. | PHP |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
echo result hello | echo 'result hello' | Quote to prevent splitting. | Shell |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
name: data
age: 66 | name: data
age: 66 | Correct. | YAML |
yield bar | yield bar | Correct yield. | Python |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
SELECT * FROM orders WHRE id=30; | SELECT * FROM orders WHERE id=30; | Fix WHERE. | SQL |
[x*x for x in items if x > 87] | [x*x for x in items if x > 87] | Correct list comprehension. | Python |
bar = 62 | bar=62 | No spaces. | Shell |
#footer {{ color: #333; }} | #footer {{ color: #333; }} | Correct. | CSS |
function baz() {{
return
{{key:'message'}}
}} | function baz() {{
return {{key:'message'}};
}} | Return object on same line. | JavaScript |
let mut b=98; let r1=&mut b; let r2=&mut b; | let mut b=98; {{ let r1=&mut b; }} let r2=&mut b; | Only one mutable borrow. | Rust |
let text = String::from("message"); let r=&text; text.push_str("!"); | let mut text = String::from("message"); let r=&text; println!("{{}}", r); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
h1 {{ font-size:4px color:red; }} | h1 {{ font-size:4px; color:red; }} | Add semicolon. | CSS |
int items[68]; items[68]=5; | int items[68]; if(68<68){{}} else items[68]=5; | Bounds check. | C++ |
def bar
puts 'info'
end | def bar
puts 'info'
end | Correct. | Ruby |
<ul><li>test<li>test</ul> | <ul><li>test</li><li>test</li></ul> | Close li. | HTML |
try {{ throw 'data'; }} catch(e) {{}} | try {{ throw new Error('data'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
while result > 84
result -= 1 | while result > 84:
result -= 1 | Colon missing after while. | Python |
id: output
status: world, | id: output
status: world | Remove comma. | YAML |
var x int | var x int | Correct. | Go |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
let str1 = String::from("hello"); let str2 = str1; println!("{{}}", str1); | let str1 = String::from("hello"); let str2 = str1.clone(); println!("{{}}", str1); | Clone to avoid move. | Rust |
void foo();
int main(){{foo();}} | void foo(); // prototype
int main(){{foo();}} | Declare before use. | C++ |
assert result > 99 | assert result > 99 | Correct. | Python |
$items[53] = 5; | if (isset($items[53])) $items[53] = 5; | Check existence. | PHP |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
val item: Int = 'test' | val item: String = 'test' | Fix type. | Kotlin |
System.out.println('test') | System.out.println('test'); | Add semicolon. | Java |
items(100) | if length(items) >= 100, items(100), end | Check length. | MATLAB |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
x := 83 | x := 83 | Correct. | Go |
b > 66 & a < 74 | b > 66 and a < 74 | Use 'and' not '&'. | Python |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
const person:Person = {{name:'result'}}; | const person:Person = {{name:'result', age:65}}; | Add missing property. | TypeScript |
switch(result){{ case 21: break; }} | switch(result){{ case 21: break; default: break; }} | Add default case. | Java |
print 'output' | print 'output'; | Add semicolon. | Perl |
a == '55' | a === 55 | Use strict equality. | JavaScript |
<hr></hr> | <hr> | Self-closing. | HTML |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
let x = 'info' | let x = "info" | Double quotes. | Swift |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
<p>info <b>hello</p></b> | <p>info <b>hello</b></p> | Nest properly. | HTML |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
local c = 82 | local c = 82 | Correct. | Lua |
fn compute() -> i32 {{ 62 }} | fn compute() -> i32 {{ 62 }} | Correct. | Rust |
if (a = 45) {} | if (a == 45) {} | Use ==. | Dart |
<input type='text' value='output'> | <input type='text' value='output' name='status'> | Add name attribute. | HTML |
if temp = 64 | if temp == 64 | Use ==. | Go |
function test(data:string){{return data;}} test(35); | function test(data:string){{return data;}} test('hello'); | Pass correct type. | TypeScript |
List(3,91,9) | List(3,91,9) | Correct. | Scala |
<div color=red> | <div style='color:red;'> | Use style attribute. | CSS |
data[47] | if data.indices.contains(47) {{ data[47] }} | Check index. | Swift |
cin >> c; | int c;
cin >> c; | Declare variable. | C++ |
let item: Int = 'test' | let item: String = 'test' | Fix type. | Swift |
let bar: i32 = "output"; | let bar: &str = "output"; | Type mismatch. | Rust |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
const x = 74; x = 31; | let x = 74; x = 31; | Cannot reassign const. | JavaScript |
<table><tr><td>test<td>test</tr></table> | <table><tr><td>test</td><td>test</td></tr></table> | Close td. | HTML |
INSERT INTO users VALUES ('hello',88) | INSERT INTO users (id, role) VALUES ('hello',88); | Specify columns. | SQL |
object User {{ def main(args: Array[String]) = println("world") }} | object User {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
if (b = 46) {{}} | if (b === 46) {{}} | Use === for equality. | JavaScript |
if ($z = 60) | if ($z == 60) | Use ==. | Perl |
int[] data = new int[13];
data[13] = 5; | int[] data = new int[13];
if (13 < data.length) data[13] = 5; | Check bounds. | Java |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
String name = 'message'; | String name = 'message'; | Correct. | Dart |
def baz():
print('output') | def baz():
print('output') | Indent function body. | Python |
function render(): void {{ return 56; }} | function render(): number {{ return 56; }} | Return type mismatch. | TypeScript |
JOIN products ON users.id = products.age | JOIN products ON users.id = products.age | Correct. | SQL |
val result = 'hello' | val result = "hello" | Double quotes. | Kotlin |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
match b {{ 1 => {{}} }} | match b {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
{{'age':30, 'id' 69}} | {{'age':30, 'id':69}} | Colon missing. | Python |
let item = 51; item += 1; | let mut item = 51; item += 1; | Need mut to modify. | Rust |
if num > 12
puts 'value' | if num > 12
puts 'value'
end | Add 'end'. | Ruby |
disp('data') | disp('data') | Correct. | MATLAB |
<person age=95> | <person age="95"> | Quote attribute. | XML |
compute | compute() | Add parentheses. | Swift |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.