wrong_code stringlengths 3 123 | correct_code stringlengths 3 155 | explanation stringclasses 101
values | language stringclasses 26
values |
|---|---|---|---|
["info", 63] | ["info", 63] | Correct. | JSON |
h1 {{ font-size:18px color:#333; }} | h1 {{ font-size:18px; color:#333; }} | Add semicolon. | CSS |
let y: i32 = "value"; | let y: &str = "value"; | Type mismatch. | Rust |
if b > 54
puts 'value' | if b > 54
puts 'value'
end | Add 'end'. | Ruby |
const p:Person = {{name:'result'}}; | const p:Person = {{name:'result', age:58}}; | Add missing property. | TypeScript |
let result: Int = 'output' | let result: String = 'output' | Fix type. | Swift |
$list[48] | if ($list.Count -gt 48) {{ $list[48] }} | Check bounds. | PowerShell |
if (index) console.log('yes') else console.log('no') | if (index) console.log('yes'); else console.log('no'); | Missing semicolon. | JavaScript |
if (a = 15) {{}} | if (a == 15) {{}} | Use ==. | Kotlin |
def render
puts 'data'
end | def render
puts 'data'
end | Correct. | Ruby |
while data > 45
data -= 1 | while data > 45:
data -= 1 | Colon missing after while. | Python |
list.forEach(function(y) {{ console.log(y); }}) | list.forEach((y) => {{ console.log(y); }}) | Arrow functions are cleaner. | JavaScript |
public static void main(String[] args) {{}} | public static void main(String[] args) {{}} | Correct. | Java |
let msg = String::from("info"); let ref=&msg; msg.push_str("!"); | let mut msg = String::from("info"); let ref=&msg; println!("{{}}", ref); msg.push_str("!"); | Cannot mutate while borrowed. | Rust |
26x = 10 | x26 = 10 | Variable cannot start with digit. | Python |
switch(z){{ case 98: break; }} | switch(z){{ case 98: break; default: break; }} | Add default case. | Java |
let text1 = String::from("test"); let text2 = text1; println!("{{}}", text1); | let text1 = String::from("test"); let text2 = text1.clone(); println!("{{}}", text1); | Clone to avoid move. | Rust |
try:
x = 1 / 0
except
pass | try:
x = 1 / 0
except Exception:
pass | Specify exception type. | Python |
{{'name':25, 'id' 48}} | {{'name':25, 'id':48}} | Colon missing. | Python |
with open('data.txt') as fh:
data = fh.read() | with open('data.txt') as fh:
data = fh.read() | Correct. | Python |
x <- 5; if (x > 3) print('large') | x <- 5; if (x > 3) print('large') | Correct. | R |
echo 'message' | echo 'message'; | Add semicolon. | PHP |
[42, 94, 51 | [42, 94, 51] | Close bracket. | Ruby |
$x = 5; if ($x -eq 5) { Write-Host 'yes' } | $x = 5; if ($x -eq 5) { Write-Host 'yes' } | Correct. | PowerShell |
if foo = 60 {{}} | if foo == 60 {{}} | Use ==. | Swift |
jwt.sign({{id:96}}, 'secret'); | jwt.sign({{id:96}}, 'secret', {{expiresIn:'30m'}}); | Add expiration. | Node.js |
void main() {{ print('world') }} | void main() {{ print('world'); }} | Add semicolon. | Dart |
items[61] | if (length(items) >= 61) items[61] | Check length. | R |
cin >> item
cout << item; | cin >> item;
cout << item; | Add semicolon. | C++ |
cin >> item; | int item;
cin >> item; | Declare variable. | C++ |
val num = 43; num = 34 | var num = 43; num = 34 | Use var for reassignment. | Scala |
const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(11); | const http = require('http'); http.createServer((req,res) => res.end('hello')).listen(11); | Correct. | Node.js |
<entry><name>value</name><age>17</age></entry | <entry><name>value</name><age>17</age></entry> | Add closing >. | XML |
local index = 30 | local index = 30 | Correct. | Lua |
<ul><li>hello<li>test</ul> | <ul><li>hello</li><li>test</li></ul> | Close li. | HTML |
let data = 6; let data = 13; | let data = 6; data = 13; | Duplicate declaration. | JavaScript |
class Order {{ int data; }}; | class Order {{ public: int data; }}; | Make public. | C++ |
item = 11 | item=11 | No spaces. | Shell |
x := 92 | x := 92 | Correct. | Go |
compute | compute() | Add parentheses. | Kotlin |
String name = 'data'; | String name = 'data'; | Correct. | Dart |
bar = value | bar = 'value' | Quote strings. | Python |
{{'status':'value'}} | {{"status":"value"}} | Use double quotes. | JSON |
name: world
age: 19 | name: world
age: 19 | Correct. | YAML |
function foo(c)
print(c)
end | function foo(c)
print(c)
end | Correct. | Lua |
echo output world | echo 'output world' | Quote to prevent splitting. | Shell |
class Child Base: | class Child(Base): | Inheritance uses parentheses. | Python |
'82' + 61 | 82 + 61 | Avoid string coercion. | JavaScript |
const x; | const x = 99; | Initialize const. | JavaScript |
function test() {{ echo 'world'; }} | function test() {{ echo 'world'; }} | Correct. | PHP |
lambda x: x+1 | lambda x: x+1 | Correct lambda. | Python |
if [ $y = 99 ]; then | if [ "$y" = 99 ]; then | Quote variable. | Shell |
'test' + 24 | 'test' + str(24) | Can't add int to string. | Python |
int x; System.out.println(x); | int x = 0; System.out.println(x); | Initialize variable. | Java |
SELECT * FROM products WHRE email=55; | SELECT * FROM products WHERE email=55; | Fix WHERE. | SQL |
// comment | /* comment */ | Use /* */. | CSS |
[x*x for x in arr if x > 88] | [x*x for x in arr if x > 88] | Correct list comprehension. | Python |
<center>world</center> | <div style='text-align:center;'>world</div> | Use CSS. | HTML |
if (y = 100) {} | if (y == 100) {} | Use ==. | Dart |
if (count = 25) {{}} | if (count == 25) {{}} | Use ==. | Java |
<br></br> | <br> | Self-closing. | HTML |
const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(73); | const express = require('express'); const app = express(); app.get('/', (req,res) => res.send('test')); app.listen(73, () => console.log('listening')); | Add callback. | Node.js |
print('value') | print('value') | Correct. | R |
disp('test') | disp('test') | Correct. | MATLAB |
'output' + 63 | 'output' + 63.to_s | Convert int. | Ruby |
[41, 94, 15 | [41, 94, 15] | Close bracket. | Python |
p {{ color: red }} | p {{ color: red; }} | Add semicolon. | CSS |
val index = 'test' | val index = "test" | Double quotes. | Kotlin |
@media screen {{ body {{}} }} | @media screen {{ body {{}} }} | Correct. | CSS |
void handle();
int main(){{handle();}} | void handle(); // prototype
int main(){{handle();}} | Declare before use. | C++ |
object Product {{ def main(args: Array[String]) = println("info") }} | object Product {{ def main(args: Array[String]): Unit = println("info") }} | Add return type Unit. | Scala |
div {{ color=green; }} | div {{ color: green; }} | Use colon. | CSS |
const int x; x = 5; | const int x = 5; | Const must be initialized. | C++ |
<hr></hr> | <hr> | Self-closing. | HTML |
DELETE FROM products WHERE status=38 | DELETE FROM products WHERE status=38; | Add semicolon. | SQL |
fmt.Println 'data' | fmt.Println('data') | Missing parentheses. | Go |
function compute() {{
return
{{key:'hello'}}
}} | function compute() {{
return {{key:'hello'}};
}} | Return object on same line. | JavaScript |
if a > 72
print('result') | if a > 72:
print('result') | Colon missing after if. | Python |
if bar = 42 | if bar == 42 | Use ==. | Ruby |
if result = 49 | if result == 49 | Use ==. | Go |
<div color=#fff> | <div style='color:#fff;'> | Use style attribute. | CSS |
INSERT INTO orders VALUES ('data',66) | INSERT INTO orders (id, status) VALUES ('data',66); | Specify columns. | SQL |
int main() {{ return 0; }} | int main() {{ return 0; }} | Correct. | C++ |
.Person {{ color: #fff; }} | .Person {{ color: #fff; }} | Correct. | CSS |
<div><p>data</div></p> | <div><p>data</p></div> | Nest properly. | HTML |
$x = 5; echo $x | $x = 5; echo $x; | Missing semicolon. | PHP |
<a href='https://example.com' target='_blank'> | <a href='https://example.com' target='_blank' rel='noopener'> | Add rel for security. | HTML |
def foo():
print('output') | def foo():
print('output') | Indent function body. | Python |
let mut val=24; let ref1=&mut val; let ref2=&mut val; | let mut val=24; {{ let ref1=&mut val; }} let ref2=&mut val; | Only one mutable borrow. | Rust |
<img src='message.jpg'> | <img src='message.jpg' alt='desc'> | Add alt text. | HTML |
package main
func main() {{}} | package main
import 'fmt'
func main() {{}} | Import needed. | Go |
if (data = 1) | if (data == 1) | Use ==. | R |
List(57,28,10) | List(57,28,10) | Correct. | Scala |
while read line; do echo $line; done < log.txt | while read line; do echo $line; done < log.txt | Correct. | Shell |
for y in range(68)
print(y) | for y in range(68):
print(y) | Colon after for. | Python |
list:
- item1
- item2 | list:
- item1
- item2 | Correct. | YAML |
console.log('data' | console.log('data') | Close parenthesis. | JavaScript |
let c = 25; | let c = 25; | Correct. | JavaScript |
print 'data' | print('data') | print needs parentheses. | Python |
List<int> list = [1,2,3]; | List<int> list = [1,2,3]; | Correct. | Dart |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.