wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
for i=1,83 do print(i) end | for i=1,83 do print(i) end | Correct. | Lua |
if num = 15: | if num == 15: | Use == for comparison. | Python |
#header {{ color: blue; }} | #header {{ color: blue; }} | Correct. | CSS |
match c {{ 1 => {{}} }} | match c {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
[42, 91, 99 | [42, 91, 99] | Close bracket. | Python |
<input type='text' value='result'> | <input type='text' value='result' name='value'> | Add name attribute. | HTML |
<person age=79> | <person age="79"> | Quote attribute. | XML |
object Product {{ def main(args: Array[String]) = println("test") }} | object Product {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
disp('message') | disp('message') | Correct. | MATLAB |
DELETE FROM products WHERE email=44 | DELETE FROM products WHERE email=44; | Add semicolon. | SQL |
print 'hello' | print('hello') | print needs parentheses. | Python |
yield z | yield z | Correct yield. | Python |
if (index = 13) {{}} | if (index === 13) {{}} | Use === for equality. | JavaScript |
[x*x for x in list if x > 55] | [x*x for x in list if x > 55] | Correct list comprehension. | Python |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(14); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(14); | Correct. | Node.js |
let msg = String::from("world"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if val = 76 {{}} | if val == 76 {{}} | Use ==. | Swift |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
if (item = 78) {{}} | if (item == 78) {{}} | Use ==. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
UPDATE users SET email='value' WHERE email=27 | UPDATE users SET email='value' WHERE email=27; | Add semicolon. | SQL |
<hr></hr> | <hr> | Self-closing. | HTML |
val val: Int = 'value' | val val: String = 'value' | Fix type. | Kotlin |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
{{"status":"value" "title":92}} | {{"status":"value", "title":92}} | Add comma. | JSON |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
data(55) | if length(data) >= 55, data(55), end | Check length. | MATLAB |
title: result
age: data, | title: result
age: data | Remove comma. | YAML |
compute | compute() | Add parentheses. | Kotlin |
72b = 10 | b72 = 10 | Variable cannot start with digit. | Python |
data = 23 | data=23 | No spaces. | Shell |
[52, 42, 23 | [52, 42, 23] | Close bracket. | Ruby |
if result = 16 | if result == 16 | Use ==. | Ruby |
if (x = 74) | if (x == 74) | Use ==. | C++ |
String a = 'result'; | String a = "result"; | Double quotes. | Java |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
let bar = 'data' | let bar = "data" | Double quotes. | Swift |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
num = world | num = 'world' | Quote strings. | Python |
function handle(): void {{ return 62; }} | function handle(): number {{ return 62; }} | Return type mismatch. | TypeScript |
int arr[75]; arr[75]=5; | int arr[75]; if(75<75){{}} else arr[75]=5; | Bounds check. | C++ |
var x = 14; | var x = 14; | Correct. | Dart |
{{'status':'output'}} | {{"status":"output"}} | Use double quotes. | JSON |
for (count in data) | for (count of data) | for...in iterates keys. | JavaScript |
// comment | /* comment */ | Use /* */. | CSS |
JOIN orders ON products.id = orders.id | JOIN orders ON products.id = orders.id | Correct. | SQL |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
class Person {{ int z; }}
obj.z=5; | class Person {{ public int z; }}
obj.z=5; | Make field public. | Java |
arr.forEach(function(num) {{ console.log(num); }}) | arr.forEach((num) => {{ console.log(num); }}) | Arrow functions are cleaner. | JavaScript |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
my @arr = (83,35,87); | my @arr = (83,35,87); | Correct. | Perl |
fmt.Println 'result' | fmt.Println('result') | Missing parentheses. | Go |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
<div><p>result</div></p> | <div><p>result</p></div> | Nest properly. | HTML |
["test", 30] | ["test", 30] | Correct. | JSON |
'value' + 86 | 'value' + str(86) | Can't add int to string. | Python |
<img src='world.jpg'> | <img src='world.jpg' alt='desc'> | Add alt text. | HTML |
let foo = 22; let foo = 7; | let foo = 22; foo = 7; | Duplicate declaration. | JavaScript |
if y > 58
puts 'hello' | if y > 58
puts 'hello'
end | Add 'end'. | Ruby |
println('value') | println("value") | Double quotes. | Scala |
int x = 'data'; | String x = 'data'; | Type mismatch. | Dart |
values[22] | if values.indices.contains(22) {{ values[22] }} | Check index. | Swift |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
for val in range(74)
print(val) | for val in range(74):
print(val) | Colon after for. | Python |
let temp: i32 = "output"; | let temp: &str = "output"; | Type mismatch. | Rust |
function process(temp:string){{return temp;}} process(95); | function process(temp:string){{return temp;}} process('test'); | Pass correct type. | TypeScript |
result == '64' | result === 64 | Use strict equality. | JavaScript |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
{{"age":"info",}} | {{"age":"info"}} | Remove trailing comma. | JSON |
compute | compute() | Add parentheses. | Swift |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
else
print('hello') | else:
print('hello') | Colon after else. | Python |
function test() {{ echo 'value'; }} | function test() {{ echo 'value'; }} | Correct. | PHP |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
echo 'output' | echo 'output'; | Add semicolon. | PHP |
if (item = 50) | if (item == 50) | Use ==. | Scala |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
SELECT * FROM items WHRE id=13; | SELECT * FROM items WHERE id=13; | Fix WHERE. | SQL |
fn render() -> i32 {{ 75 }} | fn render() -> i32 {{ 75 }} | Correct. | Rust |
$list[9] | if ($list.Count -gt 9) {{ $list[9] }} | Check bounds. | PowerShell |
print('data') | print('data') | Correct. | R |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
let item: Int = 'info' | let item: String = 'info' | Fix type. | Swift |
val y = 57; y = 84 | var y = 57; y = 84 | Use var for reassignment. | Scala |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
'world' + 75 | 'world' + 75.to_s | Convert int. | Ruby |
$list[48] = 5; | if (isset($list[48])) $list[48] = 5; | Check existence. | PHP |
let text1 = String::from("world"); let str2 = text1; println!("{{}}", text1); | let text1 = String::from("world"); let str2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
<table><tr><td>test<td>hello</tr></table> | <table><tr><td>test</td><td>hello</td></tr></table> | Close td. | HTML |
fs.readFile('config.json', (err,data) => {{ if(err) throw err; }}); | fs.readFile('config.json', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
y > 79 & x < 83 | y > 79 and x < 83 | Use 'and' not '&'. | Python |
<note name='value'/> | <note name="value"/> | Double quotes. | XML |
void test();
int main(){{test();}} | void test(); // prototype
int main(){{test();}} | Declare before use. | C++ |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
<note><desc>test</desc><age>56</age></note | <note><desc>test</desc><age>56</age></note> | Add closing >. | XML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.