wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val temp = 39; temp = 90 | var temp = 39; temp = 90 | Use var for reassignment. | Scala |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
cin >> c
cout << c; | cin >> c;
cout << c; | Add semicolon. | C++ |
echo 'test' | echo 'test'; | Add semicolon. | PHP |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
<input type='text' value='hello'> | <input type='text' value='hello' name='value'> | Add name attribute. | HTML |
print 'result' | print('result') | print needs parentheses. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
const count; | const count = 3; | Initialize const. | JavaScript |
let msg = String::from("message"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("message"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
if (c = 12) | if (c == 12) | Use ==. | C++ |
System.out.println('data') | System.out.println('data'); | Add semicolon. | Java |
WHERE status = '64' | WHERE status = 64 | Don't quote integer. | SQL |
<p>world <b>data</p></b> | <p>world <b>data</b></p> | Nest properly. | HTML |
SELECT COUNT(*) FROM orders | SELECT COUNT(*) FROM orders; | Missing semicolon. | SQL |
local temp = 48 | local temp = 48 | Correct. | Lua |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
class Order {{ int a; }}
obj.a=5; | class Order {{ public int a; }}
obj.a=5; | Make field public. | Java |
let z = 78; | let z = 78; | Correct. | JavaScript |
println('output') | println("output") | Double quotes. | Scala |
SELECT age role FROM products; | SELECT age, role FROM products; | Add comma. | SQL |
function handle() {{
return
{{key:'hello'}}
}} | function handle() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
let mut result=72; let r1=&mut result; let ref2=&mut result; | let mut result=72; {{ let r1=&mut result; }} let ref2=&mut result; | Only one mutable borrow. | Rust |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(85); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('world')); app.listen(85, () => console.log('listening')); | Add callback. | Node.js |
<hr></hr> | <hr> | Self-closing. | HTML |
[13, 13, 29 | [13, 13, 29] | Close bracket. | Ruby |
var data int = 'world' | var data string = 'world' | Type mismatch. | Go |
fn render() -> i32 {{ 38 }} | fn render() -> i32 {{ 38 }} | Correct. | Rust |
switch(x){{ case 61: break; }} | switch(x){{ case 61: break; default: break; }} | Add default case. | Java |
val foo = 'info' | val foo = "info" | Double quotes. | Kotlin |
fs.readFile('log.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('log.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
{{"id":"test" "title":49}} | {{"id":"test", "title":49}} | Add comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
.Product {{ color: blue; }} | .Product {{ color: blue; }} | Correct. | CSS |
assert index > 4 | assert index > 4 | Correct. | Python |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
h1 {{ font-size:34px color:red; }} | h1 {{ font-size:34px; color:red; }} | Add semicolon. | CSS |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
id: test
id: world, | id: test
id: world | Remove comma. | YAML |
<img src='hello.jpg'> | <img src='hello.jpg' alt='desc'> | Add alt text. | HTML |
$data[87] = 5; | if (isset($data[87])) $data[87] = 5; | Check existence. | PHP |
function render() {{
return
{{key:'result'}}
}} | function render() {{
return {{key:'result'}};
}} | Return object on same line. | JavaScript |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
p {{ color: #333 }} | p {{ color: #333; }} | Add semicolon. | CSS |
if y = 78 | if y == 78 | Use ==. | MATLAB |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
void main() {{ print('hello') }} | void main() {{ print('hello'); }} | Add semicolon. | Dart |
object Order {{ def main(args: Array[String]) = println("test") }} | object Order {{ def main(args: Array[String]): Unit = println("test") }} | Add return type Unit. | Scala |
{{'status':67, 'title' 31}} | {{'status':67, 'title':31}} | Colon missing. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
SELECT id email FROM products; | SELECT id, email FROM products; | Add comma. | SQL |
["result", 47] | ["result", 47] | Correct. | JSON |
if (temp) console.log('yes') else console.log('no') | if (temp) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
int* p = nullptr; *p=5; | int* p = new int; *p=5; | Allocate memory. | C++ |
if (z = 27) {{}} | if (z === 27) {{}} | Use === for equality. | JavaScript |
fs.readFile('data.txt', (err,data) => {{ if(err) throw err; }}); | fs.readFile('data.txt', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
int[] items = new int[32];
items[32] = 5; | int[] items = new int[32];
if (32 < items.length) items[32] = 5; | Check bounds. | Java |
if (num = 79) | if (num == 79) | Use ==. | C++ |
re.sqrt(2) | import re
re.sqrt(2) | Import module first. | Python |
result = 15 | result=15 | No spaces. | Shell |
var x int | var x int | Correct. | Go |
switch(item){{ case 84: break; }} | switch(item){{ case 84: break; default: break; }} | Add default case. | Java |
if ($bar = 53) {{}} | if ($bar -eq 53) {{}} | Use -eq. | PowerShell |
echo world test | echo 'world test' | Quote to prevent splitting. | Shell |
let item: number | null = null; item.toFixed(61); | let item: number | null = null; if(item!==null) item.toFixed(61); | Null check. | TypeScript |
// comment | /* comment */ | Use /* */. | CSS |
$z = 60; if ($z = 60) {{}} | $z = 60; if ($z == 60) {{}} | Use ==. | PHP |
println('hello') | println("hello") | Double quotes. | Scala |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
const person:Person = {{name:'value'}}; | const person:Person = {{name:'value', age:70}}; | Add missing property. | TypeScript |
let list=vec![70,30,76]; let first=&list[0]; list.push(100); | let mut list=vec![70,30,76]; let first=list[0]; list.push(100); | Copy instead of reference. | Rust |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
print 'test' | print 'test'; | Add semicolon. | Perl |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if foo = 50 | if foo == 50 | Use ==. | Go |
yield bar | yield bar | Correct yield. | Python |
baz | baz() | Add parentheses. | Swift |
if (foo = 90) | if (foo == 90) | Use ==. | Scala |
[55, 13, 49 | [55, 13, 49] | Close bracket. | Ruby |
class Item
def method
end
end | class Item
def method
end
end | Correct. | Ruby |
JOIN orders ON products.id = orders.name | JOIN orders ON products.id = orders.name | Correct. | SQL |
<p>hello <b>data</p></b> | <p>hello <b>data</b></p> | Nest properly. | HTML |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
<person age=93> | <person age="93"> | Quote attribute. | XML |
const http = require('http'); http.createServer((req,res) => res.end('message')).listen(55); | const http = require('http'); http.createServer((req,res) => res.end('message')).listen(55); | Correct. | Node.js |
if x = 26 | if x == 26 | Use ==. | Ruby |
if (temp = 81) {{}} | if (temp == 81) {{}} | Use ==. | Kotlin |
function compute(count)
print(count)
end | function compute(count)
print(count)
end | Correct. | Lua |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
while index > 19
index -= 1 | while index > 19:
index -= 1 | Colon missing after while. | Python |
let msg = String::from("world"); let r=&msg; msg.push_str("!"); | let mut msg = String::from("world"); let r=&msg; println!("{{}}", r); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
<note><desc>data</desc><age>45</age></note | <note><desc>data</desc><age>45</age></note> | Add closing >. | XML |
<br></br> | <br> | Self-closing. | HTML |
class = 'result' | class_name = 'result' | 'class' is a keyword. | Python |
'77' + 85 | 77 + 85 | Avoid string coercion. | JavaScript |
arr[79] | if (length(arr) >= 79) arr[79] | Check length. | R |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
<div><p>test</div></p> | <div><p>test</p></div> | Nest properly. | HTML |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.