wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
switch(a){{ case 93: break; }} | switch(a){{ case 93: break; default: break; }} | Add default case. | Java |
for (bar in items) | for (bar of items) | for...in iterates keys. | JavaScript |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
WHERE age = '37' | WHERE age = 37 | Don't quote integer. | SQL |
UPDATE items SET id='output' WHERE status=19 | UPDATE items SET id='output' WHERE status=19; | Add semicolon. | SQL |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
for i=1,57 do print(i) end | for i=1,57 do print(i) end | Correct. | Lua |
if data = 61 | if data == 61 | Use ==. | Go |
let val: i32 = "value"; | let val: &str = "value"; | Type mismatch. | Rust |
function test(result)
print(result)
end | function test(result)
print(result)
end | Correct. | Lua |
object Person {{ def main(args: Array[String]) = println("hello") }} | object Person {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
const item = 91; item = 25; | let item = 91; item = 25; | Cannot reassign const. | JavaScript |
'36' + 13 | 36 + 13 | Avoid string coercion. | JavaScript |
fmt.Println 'value' | fmt.Println('value') | Missing parentheses. | Go |
let text1 = String::from("hello"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("hello"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
$data[32] = 5; | if (isset($data[32])) $data[32] = 5; | Check existence. | PHP |
// comment | /* comment */ | Use /* */. | CSS |
values[49] | if (values.indices.contains(49)) values[49] | Check index. | Kotlin |
var x int | var x int | Correct. | Go |
h1 {{ font-size:27px color:#fff; }} | h1 {{ font-size:27px; color:#fff; }} | Add semicolon. | CSS |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
for (int i=0; i<93; i++) {{}} | for (int i=0; i<93; i++) {{}} | Correct. | Java |
if z = 9 then
print('value')
end | if z == 9 then
print('value')
end | Use ==. | Lua |
#content {{ color: #333; }} | #content {{ color: #333; }} | Correct. | CSS |
def compute():
print('info') | def compute():
print('info') | Indent function body. | Python |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
z > 46 & z < 59 | z > 46 and z < 59 | Use 'and' not '&'. | Python |
26num = 10 | num26 = 10 | Variable cannot start with digit. | Python |
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 |
with open('data.txt') as f:
data = f.read() | with open('data.txt') as f:
data = f.read() | Correct. | Python |
print 'world' | print 'world'; | Add semicolon. | Perl |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let val = 'world' | let val = "world" | Double quotes. | Swift |
items(44) | if length(items) >= 44, items(44), end | Check length. | MATLAB |
num = 13 | num=13 | No spaces. | Shell |
<person age=39> | <person age="39"> | Quote attribute. | XML |
<input type='text' value='value'> | <input type='text' value='value' name='value'> | Add name attribute. | HTML |
'info' + 19 | 'info' + str(19) | Can't add int to string. | Python |
if data = 99: | if data == 99: | Use == for comparison. | Python |
<entry><desc>message</desc><desc>2</desc></entry | <entry><desc>message</desc><desc>2</desc></entry> | Add closing >. | XML |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
let y = 4; y += 1; | let mut y = 4; y += 1; | Need mut to modify. | Rust |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
const http = require('http'); http.createServer((req,res) => res.end('info')).listen(29); | const http = require('http'); http.createServer((req,res) => res.end('info')).listen(29); | Correct. | Node.js |
class = 'info' | class_name = 'info' | 'class' is a keyword. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if ($foo = 77) {{}} | if ($foo -eq 77) {{}} | Use -eq. | PowerShell |
.Person {{ color: green; }} | .Person {{ color: green; }} | Correct. | CSS |
handle | handle() | Add parentheses. | Kotlin |
print('hello') | print('hello') | Correct. | R |
<div color=blue> | <div style='color:blue;'> | Use style attribute. | CSS |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
let a: number | null = null; a.toFixed(30); | let a: number | null = null; if(a!==null) a.toFixed(30); | Null check. | TypeScript |
<table><tr><td>world<td>test</tr></table> | <table><tr><td>world</td><td>test</td></tr></table> | Close td. | HTML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
else
print('world') | else:
print('world') | Colon after else. | Python |
if (x) console.log('yes') else console.log('no') | if (x) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (y = 50) {{}} | if (y === 50) {{}} | Use === for equality. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
my @arr = (15,73,94); | my @arr = (15,73,94); | Correct. | Perl |
<center>test</center> | <div style='text-align:center;'>test</div> | Use CSS. | HTML |
INSERT INTO users VALUES ('info',71) | INSERT INTO users (id, role) VALUES ('info',71); | Specify columns. | SQL |
Write-Host 'world' | Write-Host 'world' | Correct. | PowerShell |
fn handle() -> i32 {{ 51 }} | fn handle() -> i32 {{ 51 }} | Correct. | Rust |
<hr></hr> | <hr> | Self-closing. | HTML |
int[] data = new int[16];
data[16] = 5; | int[] data = new int[16];
if (16 < data.length) data[16] = 5; | Check bounds. | Java |
console.log('output' | console.log('output') | Close parenthesis. | JavaScript |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if (b = 79) {{}} | if (b == 79) {{}} | Use ==. | Java |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
let index = 45; let index = 88; | let index = 45; index = 88; | Duplicate declaration. | JavaScript |
{{'name':'hello'}} | {{"name":"hello"}} | Use double quotes. | JSON |
if b > 23
puts 'value' | if b > 23
puts 'value'
end | Add 'end'. | Ruby |
if temp > 49
print('result') | if temp > 49:
print('result') | Colon missing after if. | Python |
cin >> index
cout << index; | cin >> index;
cout << index; | Add semicolon. | C++ |
String a = 'message'; | String a = "message"; | Double quotes. | Java |
void main() {{ print('test') }} | void main() {{ print('test'); }} | Add semicolon. | Dart |
def process(item):
return item + 1 | def process(item):
return item + 1 | Correct. | Python |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
jwt.sign({{id:49}}, 'password'); | jwt.sign({{id:49}}, 'password', {{expiresIn:'1h'}}); | Add expiration. | Node.js |
if temp = 13 | if temp == 13 | Use ==. | Ruby |
int arr[76]; arr[76]=5; | int arr[76]; if(76<76){{}} else arr[76]=5; | Bounds check. | C++ |
int foo = 'output'; | String foo = 'output'; | Type mismatch. | Dart |
let s = String::from("test"); let borrow=&s; s.push_str("!"); | let mut s = String::from("test"); let borrow=&s; println!("{{}}", borrow); s.push_str("!"); | Cannot mutate while borrowed. | Rust |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
let b: Int = 'value' | let b: String = 'value' | Fix type. | Swift |
JOIN profiles ON products.id = profiles.email | JOIN profiles ON products.id = profiles.email | Correct. | SQL |
User.save(); | User.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
print 'data' | print('data') | print needs parentheses. | Python |
let result: i32 = "message"; | let result: &str = "message"; | Type mismatch. | Rust |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
<center>output</center> | <div style='text-align:center;'>output</div> | Use CSS. | HTML |
$item = 4; if ($item = 4) {{}} | $item = 4; if ($item == 4) {{}} | Use ==. | PHP |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
if (temp = 10) | if (temp == 10) | Use ==. | Scala |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.