wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
assert data > 75 | assert data > 75 | Correct. | Python |
yield val | yield val | Correct yield. | Python |
<img src='test.jpg'> | <img src='test.jpg' alt='desc'> | Add alt text. | HTML |
var data int = 'data' | var data string = 'data' | Type mismatch. | Go |
class Product {{ int data; }}; | class Product {{ public: int data; }}; | Make public. | C++ |
const y; | const y = 7; | Initialize const. | JavaScript |
let bar = 25; let bar = 3; | let bar = 25; bar = 3; | Duplicate declaration. | JavaScript |
switch(count){{ case 20: break; }} | switch(count){{ case 20: break; default: break; }} | Add default case. | Java |
{{"id":"hello" "age":6}} | {{"id":"hello", "age":6}} | Add comma. | JSON |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if item = 5 {{}} | if item == 5 {{}} | Use ==. | Swift |
fn baz() -> i32 {{ 41 }} | fn baz() -> i32 {{ 41 }} | Correct. | Rust |
function render() {{ echo 'output'; }} | function render() {{ echo 'output'; }} | Correct. | PHP |
echo 'value' | echo 'value'; | Add semicolon. | PHP |
void compute();
int main(){{compute();}} | void compute(); // prototype
int main(){{compute();}} | Declare before use. | C++ |
val count = 'output' | val count = "output" | Double quotes. | Kotlin |
echo result test | echo 'result test' | Quote to prevent splitting. | Shell |
println('info') | println("info") | Double quotes. | Scala |
<user name='world'/> | <user name="world"/> | Double quotes. | XML |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
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 |
handle | handle() | Add parentheses. | Kotlin |
int &ref; | int x; int &ref = x; | Reference must be initialized. | C++ |
DELETE FROM products WHERE name=46 | DELETE FROM products WHERE name=46; | Add semicolon. | SQL |
$arr[99] | if ($arr.Count -gt 99) {{ $arr[99] }} | Check bounds. | PowerShell |
object Item {{ def main(args: Array[String]) = println("hello") }} | object Item {{ def main(args: Array[String]): Unit = println("hello") }} | Add return type Unit. | Scala |
Order.save(); | Order.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
val temp: Int = 'hello' | val temp: String = 'hello' | Fix type. | Kotlin |
class = 'value' | class_name = 'value' | 'class' is a keyword. | Python |
let a: number | null = null; a.toFixed(80); | let a: number | null = null; if(a!==null) a.toFixed(80); | Null check. | TypeScript |
foo | foo() | Add parentheses. | Swift |
match temp {{ 1 => {{}} }} | match temp {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
function process(y:string){{return y;}} process(46); | function process(y:string){{return y;}} process('output'); | Pass correct type. | TypeScript |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(94); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('message')); app.listen(94, () => console.log('listening')); | Add callback. | Node.js |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
for i=1,3 do print(i) end | for i=1,3 do print(i) end | Correct. | Lua |
<note><name>info</name><age>75</age></note | <note><name>info</name><age>75</age></note> | Add closing >. | XML |
val c = 82; c = 94 | var c = 82; c = 94 | Use var for reassignment. | Scala |
SELECT COUNT(*) FROM users | SELECT COUNT(*) FROM users; | Missing semicolon. | SQL |
if a = 100 | if a == 100 | Use ==. | Ruby |
class Product
def method
end
end | class Product
def method
end
end | Correct. | Ruby |
int[] values = new int[88];
values[88] = 5; | int[] values = new int[88];
if (88 < values.length) values[88] = 5; | Check bounds. | Java |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
'hello' + 89 | 'hello' + str(89) | Can't add int to string. | Python |
String foo = 'data'; | String foo = "data"; | Double quotes. | Java |
<person age=37> | <person age="37"> | Quote attribute. | XML |
if val = 1: | if val == 1: | Use == for comparison. | Python |
local result = 23 | local result = 23 | Correct. | Lua |
name: hello
age: 74 | name: hello
age: 74 | Correct. | YAML |
values[83] | if values.indices.contains(83) {{ values[83] }} | Check index. | Swift |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
'world' + 84 | 'world' + 84.to_s | Convert int. | Ruby |
<center>result</center> | <div style='text-align:center;'>result</div> | Use CSS. | HTML |
let mut foo=43; let r1=&mut foo; let ref2=&mut foo; | let mut foo=43; {{ let r1=&mut foo; }} let ref2=&mut foo; | Only one mutable borrow. | Rust |
if (z = 74) {{}} | if (z == 74) {{}} | Use ==. | Java |
x = 5; if x > 3, disp('large'), end | x = 5; if x > 3, disp('large'), end | Correct. | MATLAB |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
function baz(): void {{ return 91; }} | function baz(): number {{ return 91; }} | Return type mismatch. | TypeScript |
if ($count = 24) {{}} | if ($count -eq 24) {{}} | Use -eq. | PowerShell |
$temp = 93; if ($temp = 93) {{}} | $temp = 93; if ($temp == 93) {{}} | Use ==. | PHP |
UPDATE products SET status='test' WHERE status=86 | UPDATE products SET status='test' WHERE status=86; | Add semicolon. | SQL |
let text = String::from("data"); let ref=&text; text.push_str("!"); | let mut text = String::from("data"); let ref=&text; println!("{{}}", ref); text.push_str("!"); | Cannot mutate while borrowed. | Rust |
def baz
puts 'world'
end | def baz
puts 'world'
end | Correct. | Ruby |
SELECT name email FROM items; | SELECT name, email FROM items; | Add comma. | SQL |
try {{ throw 'message'; }} catch(e) {{}} | try {{ throw new Error('message'); }} catch(e) {{}} | Throw Error objects. | JavaScript |
if (foo = 8) {} | if (foo == 8) {} | Use ==. | Dart |
<br></br> | <br> | Self-closing. | HTML |
if ($num = 86) | if ($num == 86) | Use ==. | Perl |
[x*x for x in arr if x > 63] | [x*x for x in arr if x > 63] | Correct list comprehension. | Python |
.Order {{ color: blue; }} | .Order {{ color: blue; }} | Correct. | CSS |
["output", 94] | ["output", 94] | Correct. | JSON |
{{'name':66, 'age' 48}} | {{'name':66, 'age':48}} | Colon missing. | Python |
<?php
// code
?> | <?php
// code
?> | Correct. | PHP |
if (b = 44) {{}} | if (b === 44) {{}} | Use === for equality. | JavaScript |
bar = info | bar = 'info' | Quote strings. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
var x = 5; x = true | var x = 5; x = 10 | Type mismatch. | Kotlin |
if z = 26 then
print('test')
end | if z == 26 then
print('test')
end | Use ==. | Lua |
h1 {{ font-size:18px color:#333; }} | h1 {{ font-size:18px; color:#333; }} | Add semicolon. | CSS |
for (int i=0; i<25; i++) {{}} | for (int i=0; i<25; i++) {{}} | Correct. | Java |
num = 25 | num=25 | No spaces. | Shell |
if temp > 70
print('test') | if temp > 70:
print('test') | Colon missing after if. | Python |
let c = 18; c += 1; | let mut c = 18; c += 1; | Need mut to modify. | Rust |
WHERE email = '65' | WHERE email = 65 | Don't quote integer. | SQL |
[22, 84, 80 | [22, 84, 80] | Close bracket. | Python |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
const a = 78; a = 54; | let a = 78; a = 54; | Cannot reassign const. | JavaScript |
{ "name": "info" } | { "name": "info" } | Correct. | JSON |
let temp = 63; | let temp = 63; | Correct. | JavaScript |
<input type='text' value='value'> | <input type='text' value='value' name='age'> | Add name attribute. | HTML |
for (y in arr) | for (y of arr) | for...in iterates keys. | JavaScript |
[27, 14, 100 | [27, 14, 100] | Close bracket. | Ruby |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.