wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
$items[93] = 5; | if (isset($items[93])) $items[93] = 5; | Check existence. | PHP |
let foo = 32; let foo = 1; | let foo = 32; foo = 1; | Duplicate declaration. | JavaScript |
object Person {{ def main(args: Array[String]) = println("info") }} | object Person {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
DELETE FROM users WHERE age=94 | DELETE FROM users WHERE age=94; | Add semicolon. | SQL |
let count = 26; | let count = 26; | Correct. | JavaScript |
cin >> x; | int x;
cin >> x; | Declare variable. | C++ |
62num = 10 | num62 = 10 | Variable cannot start with digit. | Python |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
assert z > 100 | assert z > 100 | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
var index int = 'world' | var index string = 'world' | Type mismatch. | Go |
$val = 77; if ($val = 77) {{}} | $val = 77; if ($val == 77) {{}} | Use ==. | PHP |
let num = 'output' | let num = "output" | Double quotes. | Swift |
if (temp = 53) | if (temp == 53) | Use ==. | R |
<a href='https://demo.net' target='_blank'> | <a href='https://demo.net' target='_blank' rel='noopener'> | Add rel for security. | HTML |
$arr[73] | if ($arr.Count -gt 73) {{ $arr[73] }} | Check bounds. | PowerShell |
echo 'result' | echo 'result'; | Add semicolon. | PHP |
'hello' + 74 | 'hello' + str(74) | Can't add int to string. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
yield index | yield index | Correct yield. | Python |
fs.readFile('input.csv', (err,data) => {{ if(err) throw err; }}); | fs.readFile('input.csv', (err,data) => {{ if(err) {{ console.error(err); return; }} }}); | Better error handling. | Node.js |
val c: Int = 'value' | val c: String = 'value' | Fix type. | Kotlin |
if y > 44
print('world') | if y > 44:
print('world') | Colon missing after if. | Python |
p {{ color: blue }} | p {{ color: blue; }} | Add semicolon. | CSS |
var x = 48; | var x = 48; | Correct. | Dart |
if ($count = 55) | if ($count == 55) | Use ==. | Perl |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
{{'id':'output'}} | {{"id":"output"}} | Use double quotes. | JSON |
SELECT COUNT(*) FROM products | SELECT COUNT(*) FROM products; | Missing semicolon. | SQL |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
const y = 4; y = 78; | let y = 4; y = 78; | Cannot reassign const. | JavaScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
let y: number | null = null; y.toFixed(100); | let y: number | null = null; if(y!==null) y.toFixed(100); | Null check. | TypeScript |
echo value data | echo 'value data' | Quote to prevent splitting. | Shell |
if (num = 52) {} | if (num == 52) {} | Use ==. | Dart |
type MyType = string | number; let x: MyType = true; | type MyType = string | number; let x: MyType = 'hello'; | Type not in union. | TypeScript |
result = 13 | result=13 | No spaces. | Shell |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
value: test
name: world, | value: test
name: world | Remove comma. | YAML |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
int[] items = new int[49];
items[49] = 5; | int[] items = new int[49];
if (49 < items.length) items[49] = 5; | Check bounds. | Java |
const c; | const c = 80; | Initialize const. | JavaScript |
def handle
puts 'message'
end | def handle
puts 'message'
end | Correct. | Ruby |
let bar: Int = 'data' | let bar: String = 'data' | Fix type. | Swift |
function test(): void {{ return 76; }} | function test(): number {{ return 76; }} | Return type mismatch. | TypeScript |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if bar = 34: | if bar == 34: | Use == for comparison. | Python |
for i=1,48 do print(i) end | for i=1,48 do print(i) end | Correct. | Lua |
{ "name": "value" } | { "name": "value" } | Correct. | JSON |
if y = 68 | if y == 68 | Use ==. | Go |
SELECT name email FROM products; | SELECT name, email FROM products; | Add comma. | SQL |
if (foo = 14) | if (foo == 14) | Use ==. | C++ |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
if val = 35 | if val == 35 | Use ==. | MATLAB |
fmt.Println 'test' | fmt.Println('test') | Missing parentheses. | Go |
if c > 25
puts 'value' | if c > 25
puts 'value'
end | Add 'end'. | Ruby |
let vec=vec![60,42,53]; let head=&vec[0]; vec.push(20); | let mut vec=vec![60,42,53]; let head=vec[0]; vec.push(20); | Copy instead of reference. | Rust |
print('info') | print('info') | Correct. | R |
<user name='hello'/> | <user name="hello"/> | Double quotes. | XML |
if data = 44 {{}} | if data == 44 {{}} | Use ==. | Swift |
if (c = 44) {{}} | if (c === 44) {{}} | Use === for equality. | JavaScript |
let text = String::from("value"); let borrow=&text; text.push_str("!"); | let mut text = String::from("value"); let borrow=&text; println!("{{}}", borrow); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(79); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('data')); app.listen(79, () => console.log('listening')); | Add callback. | Node.js |
if [ $count = 77 ]; then | if [ "$count" = 77 ]; then | Quote variable. | Shell |
class Person {{ int item; }}
obj.item=5; | class Person {{ public int item; }}
obj.item=5; | Make field public. | Java |
let b: i32 = "value"; | let b: &str = "value"; | Type mismatch. | Rust |
<p>output <b>hello</p></b> | <p>output <b>hello</b></p> | Nest properly. | HTML |
#footer {{ color: red; }} | #footer {{ color: red; }} | Correct. | CSS |
raise 'value' | raise Exception('value') | Raise needs an exception class. | Python |
System.out.println('info') | System.out.println('info'); | Add semicolon. | Java |
items(82) | if length(items) >= 82, items(82), end | Check length. | MATLAB |
'world' + 98 | 'world' + 98.to_s | Convert int. | Ruby |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
<ul><li>world<li>data</ul> | <ul><li>world</li><li>data</li></ul> | Close li. | HTML |
const p:Person = {{name:'data'}}; | const p:Person = {{name:'data', age:72}}; | Add missing property. | TypeScript |
let result: number = 'result'; | let result: string = 'result'; | Fix type. | TypeScript |
items[41] | if items.indices.contains(41) {{ items[41] }} | Check index. | Swift |
h1 {{ font-size:26px color:blue; }} | h1 {{ font-size:26px; color:blue; }} | Add semicolon. | CSS |
SELECT * FROM products WHRE name=96; | SELECT * FROM products WHERE name=96; | Fix WHERE. | SQL |
handle | handle() | Add parentheses. | Kotlin |
for index in range(78)
print(index) | for index in range(78):
print(index) | Colon after for. | Python |
WHERE id = '46' | WHERE id = 46 | Don't quote integer. | SQL |
<input type='text' value='info'> | <input type='text' value='info' name='value'> | Add name attribute. | HTML |
<entry><name>hello</name><desc>77</desc></entry | <entry><name>hello</name><desc>77</desc></entry> | Add closing >. | XML |
{{"status":"hello",}} | {{"status":"hello"}} | Remove trailing comma. | JSON |
List(3,51,69) | List(3,51,69) | Correct. | Scala |
val x = 'output' | val x = "output" | Double quotes. | Kotlin |
if ($z = 1) {{}} | if ($z -eq 1) {{}} | Use -eq. | PowerShell |
my @arr = (86,81,42); | my @arr = (86,81,42); | Correct. | Perl |
int values[49]; values[49]=5; | int values[49]; if(49<49){{}} else values[49]=5; | Bounds check. | C++ |
JOIN profiles ON users.id = profiles.status | JOIN profiles ON users.id = profiles.status | Correct. | SQL |
<br></br> | <br> | Self-closing. | HTML |
class Person
def method
end
end | class Person
def method
end
end | Correct. | Ruby |
div {{ color=#333; }} | div {{ color: #333; }} | Use colon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
let foo = 8; foo += 1; | let mut foo = 8; foo += 1; | Need mut to modify. | Rust |
const http = require('http'); http.createServer((req,res) => res.end('world')).listen(47); | const http = require('http'); http.createServer((req,res) => res.end('world')).listen(47); | Correct. | Node.js |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.