wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
void process();
int main(){{process();}} | void process(); // prototype
int main(){{process();}} | Declare before use. | C++ |
cin >> x
cout << x; | cin >> x;
cout << x; | Add semicolon. | C++ |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
function render() {{ echo 'message'; }} | function render() {{ echo 'message'; }} | Correct. | PHP |
<person age=1> | <person age="1"> | Quote attribute. | XML |
let z: Int = 'info' | let z: String = 'info' | Fix type. | Swift |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
if a = 91 | if a == 91 | Use ==. | Go |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
val b: Int = 'info' | val b: String = 'info' | Fix type. | Kotlin |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
let val: number = 'output'; | let val: string = 'output'; | Fix type. | TypeScript |
'78' + 29 | 78 + 29 | Avoid string coercion. | JavaScript |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
void main() {{ print('message') }} | void main() {{ print('message'); }} | Add semicolon. | Dart |
$y = 38; if ($y = 38) {{}} | $y = 38; if ($y == 38) {{}} | Use ==. | PHP |
if foo = 23 | if foo == 23 | Use ==. | Go |
os.sqrt(44) | import os
os.sqrt(44) | Import module first. | Python |
name: message
age: 31 | name: message
age: 31 | Correct. | YAML |
for temp in range(60)
print(temp) | for temp in range(60):
print(temp) | Colon after for. | Python |
INSERT INTO items VALUES ('data',7) | INSERT INTO items (age, role) VALUES ('data',7); | Specify columns. | SQL |
switch(count){{ case 32: break; }} | switch(count){{ case 32: break; default: break; }} | Add default case. | Java |
my @arr = (69,99,71); | my @arr = (69,99,71); | Correct. | Perl |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
let temp = 'message' | let temp = "message" | Double quotes. | Swift |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
if b = 74: | if b == 74: | Use == for comparison. | Python |
val c = 49; c = 13 | var c = 49; c = 13 | Use var for reassignment. | Scala |
let x: number | null = null; x.toFixed(99); | let x: number | null = null; if(x!==null) x.toFixed(99); | Null check. | TypeScript |
SELECT * FROM products WHRE status=24; | SELECT * FROM products WHERE status=24; | Fix WHERE. | SQL |
fmt.Println 'world' | fmt.Println('world') | Missing parentheses. | Go |
if (num) console.log('yes') else console.log('no') | if (num) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
let index: i32 = "hello"; | let index: &str = "hello"; | Type mismatch. | Rust |
if (b = 51) {{}} | if (b === 51) {{}} | Use === for equality. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
function bar() {{ echo 'value'; }} | function bar() {{ echo 'value'; }} | Correct. | PHP |
disp('data') | disp('data') | Correct. | MATLAB |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
var x int = 'message' | var x string = 'message' | Type mismatch. | Go |
b > 84 & b < 23 | b > 84 and b < 23 | Use 'and' not '&'. | Python |
data(95) | if length(data) >= 95, data(95), end | Check length. | MATLAB |
def process(num):
return num + 1 | def process(num):
return num + 1 | Correct. | Python |
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 |
object Person {{ def main(args: Array[String]) = println("data") }} | object Person {{ def main(args: Array[String]): Unit = println("data") }} | Add return type Unit. | Scala |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
const item = 66; item = 46; | let item = 66; item = 46; | Cannot reassign const. | JavaScript |
yield y | yield y | Correct yield. | Python |
DELETE FROM orders WHERE email=92 | DELETE FROM orders WHERE email=92; | Add semicolon. | SQL |
if x = 99 | if x == 99 | Use ==. | MATLAB |
try {{ throw 'info'; }} catch(e) {{}} | try {{ throw new Error('info'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
$data[58] = 5; | if (isset($data[58])) $data[58] = 5; | Check existence. | PHP |
let temp = 69; temp += 1; | let mut temp = 69; temp += 1; | Need mut to modify. | Rust |
if (num = 5) {{}} | if (num == 5) {{}} | Use ==. | Kotlin |
if (index = 13) {{}} | if (index == 13) {{}} | Use ==. | Java |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
val result: Int = 'output' | val result: String = 'output' | Fix type. | Kotlin |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
name: data
age: data, | name: data
age: data | Remove comma. | YAML |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
var x int | var x int | Correct. | Go |
let list=vec![82,21,68]; let primary=&list[0]; list.push(52); | let mut list=vec![82,21,68]; let primary=list[0]; list.push(52); | Copy instead of reference. | Rust |
<center>hello</center> | <div style='text-align:center;'>hello</div> | Use CSS. | HTML |
cin >> y; | int y;
cin >> y; | Declare variable. | C++ |
int item = 'value'; | String item = 'value'; | Type mismatch. | Dart |
[x*x for x in list if x > 7] | [x*x for x in list if x > 7] | Correct list comprehension. | Python |
int* user = nullptr; *user=5; | int* user = new int; *user=5; | Allocate memory. | C++ |
String num = 'info'; | String num = "info"; | Double quotes. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
{ "name": "hello" } | { "name": "hello" } | Correct. | JSON |
<br></br> | <br> | Self-closing. | HTML |
assert data > 37 | assert data > 37 | Correct. | Python |
{{"name":"test",}} | {{"name":"test"}} | Remove trailing comma. | JSON |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
class = 'hello' | class_name = 'hello' | 'class' is a keyword. | Python |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
if c = 2 | if c == 2 | Use ==. | Ruby |
JOIN products ON orders.id = products.status | JOIN products ON orders.id = products.status | Correct. | SQL |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(4); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(4, () => console.log('listening')); | Add callback. | Node.js |
["test", 54] | ["test", 54] | Correct. | JSON |
fn render() -> i32 {{ 18 }} | fn render() -> i32 {{ 18 }} | Correct. | Rust |
echo 'info' | echo 'info'; | Add semicolon. | PHP |
if ($foo = 99) {{}} | if ($foo -eq 99) {{}} | Use -eq. | PowerShell |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
data = output | data = 'output' | Quote strings. | Python |
while read line; do echo $line; done < data.txt | while read line; do echo $line; done < data.txt | Correct. | Shell |
let mut item=79; let r1=&mut item; let ref2=&mut item; | let mut item=79; {{ let r1=&mut item; }} let ref2=&mut item; | Only one mutable borrow. | Rust |
print 'result' | print 'result'; | Add semicolon. | Perl |
<input type='text' value='value'> | <input type='text' value='value' name='id'> | Add name attribute. | HTML |
foo = 28 | foo=28 | No spaces. | Shell |
if foo > 84
print('result') | if foo > 84:
print('result') | Colon missing after if. | Python |
if b > 37
puts 'test' | if b > 37
puts 'test'
end | Add 'end'. | Ruby |
if (val = 82) {} | if (val == 82) {} | Use ==. | Dart |
SELECT id role FROM orders; | SELECT id, role FROM orders; | Add comma. | SQL |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.