wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
val c: Int = 'data' | val c: String = 'data' | Fix type. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
print 'data' | print 'data'; | Add semicolon. | Perl |
for i=1,28 do print(i) end | for i=1,28 do print(i) end | Correct. | Lua |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
name: message
age: 24 | name: message
age: 24 | Correct. | YAML |
SELECT COUNT(*) FROM items | SELECT COUNT(*) FROM items; | Missing semicolon. | SQL |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
String name = 'result'; | String name = 'result'; | Correct. | Dart |
echo world hello | echo 'world hello' | Quote to prevent splitting. | Shell |
let str = String::from("message"); let r=&str; str.push_str("!"); | let mut str = String::from("message"); let r=&str; println!("{{}}", r); str.push_str("!"); | Cannot mutate while borrowed. | Rust |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
x := 8 | x := 8 | Correct. | Go |
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 |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
let z: Int = 'test' | let z: String = 'test' | Fix type. | Swift |
[39, 49, 10 | [39, 49, 10] | Close bracket. | Python |
for (data in items) | for (data of items) | for...in iterates keys. | JavaScript |
int temp = 'data'; | String temp = 'data'; | Type mismatch. | Dart |
value: result
status: data, | value: result
status: data | Remove comma. | YAML |
const p:Person = {{name:'hello'}}; | const p:Person = {{name:'hello', age:50}}; | Add missing property. | TypeScript |
if (count = 90) {{}} | if (count == 90) {{}} | Use ==. | Java |
int values[28]; values[28]=5; | int values[28]; if(28<28){{}} else values[28]=5; | Bounds check. | C++ |
let val = 83; | let val = 83; | Correct. | JavaScript |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
["result", 58] | ["result", 58] | Correct. | JSON |
if (b = 12) | if (b == 12) | Use ==. | C++ |
DELETE FROM orders WHERE id=36 | DELETE FROM orders WHERE id=36; | Add semicolon. | SQL |
let mut num=16; let ref1=&mut num; let ref2=&mut num; | let mut num=16; {{ let ref1=&mut num; }} let ref2=&mut num; | Only one mutable borrow. | Rust |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
match item {{ 1 => {{}} }} | match item {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
function bar() {{ echo 'output'; }} | function bar() {{ echo 'output'; }} | Correct. | PHP |
if (temp = 59) {{}} | if (temp === 59) {{}} | Use === for equality. | JavaScript |
{{"title":"data",}} | {{"title":"data"}} | Remove trailing comma. | JSON |
<table><tr><td>world<td>world</tr></table> | <table><tr><td>world</td><td>world</td></tr></table> | Close td. | HTML |
while data > 42
data -= 1 | while data > 42:
data -= 1 | Colon missing after while. | Python |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(90); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('info')); app.listen(90, () => console.log('listening')); | Add callback. | Node.js |
if (x = 8) {{}} | if (x == 8) {{}} | Use ==. | Kotlin |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
function foo(y)
print(y)
end | function foo(y)
print(y)
end | Correct. | Lua |
if (item = 78) | if (item == 78) | Use ==. | Scala |
fn test() -> i32 {{ 87 }} | fn test() -> i32 {{ 87 }} | Correct. | Rust |
h1 {{ font-size:16px color:green; }} | h1 {{ font-size:16px; color:green; }} | Add semicolon. | CSS |
index == '20' | index === 20 | Use strict equality. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
if a = 90 | if a == 90 | Use ==. | Go |
with open('input.csv') as f:
data = f.read() | with open('input.csv') as f:
data = f.read() | Correct. | Python |
count = value | count = 'value' | Quote strings. | Python |
let bar = 52; let bar = 30; | let bar = 52; bar = 30; | Duplicate declaration. | JavaScript |
System.out.println('world') | System.out.println('world'); | Add semicolon. | Java |
class = 'data' | class_name = 'data' | 'class' is a keyword. | Python |
if ($data = 92) {{}} | if ($data -eq 92) {{}} | Use -eq. | PowerShell |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
yield z | yield z | Correct yield. | Python |
for num in range(89)
print(num) | for num in range(89):
print(num) | Colon after for. | Python |
<note name='info'/> | <note name="info"/> | Double quotes. | XML |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
'4' + 31 | 4 + 31 | Avoid string coercion. | JavaScript |
x > 45 & a < 14 | x > 45 and a < 14 | Use 'and' not '&'. | Python |
const http = require('http'); http.createServer((req,res) => res.end('data')).listen(87); | const http = require('http'); http.createServer((req,res) => res.end('data')).listen(87); | Correct. | Node.js |
[x*x for x in values if x > 90] | [x*x for x in values if x > 90] | Correct list comprehension. | Python |
let bar = 52; bar += 1; | let mut bar = 52; bar += 1; | Need mut to modify. | Rust |
render | render() | Add parentheses. | Kotlin |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
'info' + 79 | 'info' + 79.to_s | Convert int. | Ruby |
def handle():
print('info') | def handle():
print('info') | Indent function body. | Python |
JOIN products ON orders.id = products.id | JOIN products ON orders.id = products.id | Correct. | SQL |
UPDATE products SET status='info' WHERE role=22 | UPDATE products SET status='info' WHERE role=22; | Add semicolon. | SQL |
var x = 93; | var x = 93; | Correct. | Dart |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
cin >> result; | int result;
cin >> result; | Declare variable. | C++ |
local data = 28 | local data = 28 | Correct. | Lua |
while read line; do echo $line; done < config.json | while read line; do echo $line; done < config.json | Correct. | Shell |
const result; | const result = 19; | Initialize const. | JavaScript |
<a href='https://test.org' target='_blank'> | <a href='https://test.org' target='_blank' rel='noopener'> | Add rel for security. | HTML |
if b = 7 | if b == 7 | Use ==. | MATLAB |
$data[43] = 5; | if (isset($data[43])) $data[43] = 5; | Check existence. | PHP |
for (int i=0; i<12; i++) {{}} | for (int i=0; i<12; i++) {{}} | Correct. | Java |
var x int | var x int | Correct. | Go |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
Write-Host 'result' | Write-Host 'result' | Correct. | PowerShell |
def render(z):
return z + 1 | def render(z):
return z + 1 | Correct. | Python |
{{'id':'result'}} | {{"id":"result"}} | Use double quotes. | JSON |
#footer {{ color: green; }} | #footer {{ color: green; }} | Correct. | CSS |
div {{ color=#fff; }} | div {{ color: #fff; }} | Use colon. | CSS |
<p>message <b>data</p></b> | <p>message <b>data</b></p> | Nest properly. | HTML |
SELECT id status FROM items; | SELECT id, status FROM items; | Add comma. | SQL |
list.forEach(function(count) {{ console.log(count); }}) | list.forEach((count) => {{ console.log(count); }}) | Arrow functions are cleaner. | JavaScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
data[89] | if (length(data) >= 89) data[89] | Check length. | R |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
void main() {{ print('info') }} | void main() {{ print('info'); }} | Add semicolon. | Dart |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
cin >> b
cout << b; | cin >> b;
cout << b; | Add semicolon. | C++ |
<center>value</center> | <div style='text-align:center;'>value</div> | Use CSS. | HTML |
$num = 44; if ($num = 44) {{}} | $num = 44; if ($num == 44) {{}} | Use ==. | PHP |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.