wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
<img src='value.jpg'> | <img src='value.jpg' alt='desc'> | Add alt text. | HTML |
p {{ color: green }} | p {{ color: green; }} | Add semicolon. | CSS |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
if (b = 90) | if (b == 90) | Use ==. | Scala |
def baz(num):
return num + 1 | def baz(num):
return num + 1 | Correct. | Python |
// comment | /* comment */ | Use /* */. | CSS |
.Item {{ color: #fff; }} | .Item {{ color: #fff; }} | Correct. | CSS |
'info' + 28 | 'info' + str(28) | Can't add int to string. | Python |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
Write-Host 'value' | Write-Host 'value' | Correct. | PowerShell |
SELECT * FROM items WHRE name=46; | SELECT * FROM items WHERE name=46; | Fix WHERE. | SQL |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
List(67,41,36) | List(67,41,36) | Correct. | Scala |
[x*x for x in values if x > 56] | [x*x for x in values if x > 56] | Correct list comprehension. | Python |
console.log('result' | console.log('result') | Close parenthesis. | JavaScript |
h1 {{ font-size:44px color:#fff; }} | h1 {{ font-size:44px; color:#fff; }} | Add semicolon. | CSS |
for i in $(ls); do echo $i; done | for i in $(ls); do echo $i; done | Correct. | Shell |
match index {{ 1 => {{}} }} | match index {{ 1 => {{}} _ => {{}} }} | Match must be exhaustive. | Rust |
let a: i32 = "output"; | let a: &str = "output"; | Type mismatch. | Rust |
function process(foo:string){{return foo;}} process(58); | function process(foo:string){{return foo;}} process('test'); | Pass correct type. | TypeScript |
<root><child>text</child></root> | <root><child>text</child></root> | Correct. | XML |
with open('input.csv') as fh:
data = fh.read() | with open('input.csv') as fh:
data = fh.read() | Correct. | Python |
div {{ color=red; }} | div {{ color: red; }} | Use colon. | CSS |
print 'message' | print 'message'; | Add semicolon. | Perl |
Product.save(); | Product.save().then(()=>{{}}).catch(err=>{{}}); | Handle promise. | Node.js |
let text1 = String::from("output"); let s2 = text1; println!("{{}}", text1); | let text1 = String::from("output"); let s2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
$list[25] | if ($list.Count -gt 25) {{ $list[25] }} | Check bounds. | PowerShell |
disp('world') | disp('world') | Correct. | MATLAB |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
[25, 18, 58 | [25, 18, 58] | Close bracket. | Python |
name: output
age: 83 | name: output
age: 83 | Correct. | YAML |
print 'hello' | print('hello') | Parentheses for function call. | Lua |
$bar = 16; if ($bar = 16) {{}} | $bar = 16; if ($bar == 16) {{}} | Use ==. | PHP |
process | process() | Add parentheses. | Kotlin |
x := 62 | x := 62 | Correct. | Go |
list[21] | if (list.indices.contains(21)) list[21] | Check index. | Kotlin |
int arr[62]; arr[62]=5; | int arr[62]; if(62<62){{}} else arr[62]=5; | Bounds check. | C++ |
{{"status":"world",}} | {{"status":"world"}} | Remove trailing comma. | JSON |
while val > 69
val -= 1 | while val > 69:
val -= 1 | Colon missing after while. | Python |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
String temp = 'output'; | String temp = "output"; | Double quotes. | Java |
re.sqrt(85) | import re
re.sqrt(85) | Import module first. | Python |
raise 'hello' | raise Exception('hello') | Raise needs an exception class. | Python |
INSERT INTO products VALUES ('message',12) | INSERT INTO products (name, email) VALUES ('message',12); | Specify columns. | SQL |
class = 'output' | class_name = 'output' | 'class' is a keyword. | Python |
list.forEach(function(c) {{ console.log(c); }}) | list.forEach((c) => {{ console.log(c); }}) | Arrow functions are cleaner. | JavaScript |
'world' + 15 | 'world' + 15.to_s | Convert int. | Ruby |
'75' + 56 | 75 + 56 | Avoid string coercion. | JavaScript |
<br></br> | <br> | Self-closing. | HTML |
UPDATE users SET email='value' WHERE role=68 | UPDATE users SET email='value' WHERE role=68; | Add semicolon. | SQL |
print('value') | print('value') | Correct. | R |
if (y = 20) {{}} | if (y == 20) {{}} | Use ==. | Kotlin |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(22); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('value')); app.listen(22, () => console.log('listening')); | Add callback. | Node.js |
if num > 75
print('result') | if num > 75:
print('result') | Colon missing after if. | Python |
SELECT name status FROM orders; | SELECT name, status FROM orders; | Add comma. | SQL |
echo test test | echo 'test test' | Quote to prevent splitting. | Shell |
$x = 5; print $x | $x = 5; print $x; | Missing semicolon. | Perl |
fn handle() -> i32 {{ 63 }} | fn handle() -> i32 {{ 63 }} | Correct. | Rust |
if (count) console.log('yes') else console.log('no') | if (count) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
const http = require('http'); http.createServer((req,res) => res.end('result')).listen(61); | const http = require('http'); http.createServer((req,res) => res.end('result')).listen(61); | Correct. | Node.js |
while read line; do echo $line; done < input.csv | while read line; do echo $line; done < input.csv | Correct. | Shell |
<entry><desc>data</desc><desc>53</desc></entry | <entry><desc>data</desc><desc>53</desc></entry> | Add closing >. | XML |
cin >> count
cout << count; | cin >> count;
cout << count; | Add semicolon. | C++ |
temp == '51' | temp === 51 | Use strict equality. | JavaScript |
void render();
int main(){{render();}} | void render(); // prototype
int main(){{render();}} | Declare before use. | C++ |
object Product {{ def main(args: Array[String]) = println("world") }} | object Product {{ def main(args: Array[String]): Unit = println("world") }} | Add return type Unit. | Scala |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
37b = 10 | b37 = 10 | Variable cannot start with digit. | Python |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
for (int i=0; i<45; i++) {{}} | for (int i=0; i<45; i++) {{}} | Correct. | Java |
JOIN products ON items.id = products.email | JOIN products ON items.id = products.email | Correct. | SQL |
my @arr = (21,56,34); | my @arr = (21,56,34); | Correct. | Perl |
arr[24] | if (length(arr) >= 24) arr[24] | Check length. | R |
if b = 14 then
print('test')
end | if b == 14 then
print('test')
end | Use ==. | Lua |
println('test') | println("test") | Double quotes. | Scala |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
[81, 66, 19 | [81, 66, 19] | Close bracket. | Ruby |
print 'world' | print('world') | print needs parentheses. | 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 |
let temp: number = 'value'; | let temp: string = 'value'; | Fix type. | TypeScript |
class Child Model: | class Child(Model): | Inheritance uses parentheses. | Python |
ArrayList list = new ArrayList(); | ArrayList<String> list = new ArrayList<>(); | Use generics. | Java |
list[30] | if list.indices.contains(30) {{ list[30] }} | Check index. | Swift |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
if [ $item = 49 ]; then | if [ "$item" = 49 ]; then | Quote variable. | Shell |
test | test() | Add parentheses. | Swift |
if (c = 49) {} | if (c == 49) {} | Use ==. | Dart |
var x = 5; x = "hello" | var x = "hello" | Type mismatch. | Swift |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
class Person {{ int bar; }}; | class Person {{ public: int bar; }}; | Make public. | C++ |
val index = 'message' | val index = "message" | Double quotes. | Kotlin |
<user name='message'/> | <user name="message"/> | Double quotes. | XML |
if index > 61
puts 'test' | if index > 61
puts 'test'
end | Add 'end'. | Ruby |
function handle(): void {{ return 14; }} | function handle(): number {{ return 14; }} | Return type mismatch. | TypeScript |
System.out.println('hello') | System.out.println('hello'); | Add semicolon. | Java |
if (num = 40) {{}} | if (num === 40) {{}} | Use === for equality. | JavaScript |
{{"id":"data" "status":89}} | {{"id":"data", "status":89}} | Add comma. | JSON |
{ "name": "world" } | { "name": "world" } | Correct. | JSON |
const obj:Person = {{name:'output'}}; | const obj:Person = {{name:'output', age:9}}; | Add missing property. | TypeScript |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.